@@ -134,21 +134,23 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
134
134
}
135
135
}
136
136
137
- // composeGoGetImport returns go-get-import meta content.
138
- func composeGoGetImport (owner , repo string ) string {
137
+ // ComposeGoGetImport returns go-get-import meta content.
138
+ func ComposeGoGetImport (owner , repo string ) string {
139
139
return path .Join (setting .Domain , setting .AppSubURL , owner , repo )
140
140
}
141
141
142
- // earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
142
+ // EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200
143
143
// if user does not have actual access to the requested repository,
144
144
// or the owner or repository does not exist at all.
145
145
// This is particular a workaround for "go get" command which does not respect
146
146
// .netrc file.
147
- func earlyResponseForGoGetMeta (ctx * Context ) {
147
+ func EarlyResponseForGoGetMeta (ctx * Context ) {
148
+ username := ctx .Params (":username" )
149
+ reponame := ctx .Params (":reponame" )
148
150
ctx .PlainText (200 , []byte (com .Expand (`<meta name="go-import" content="{GoGetImport} git {CloneLink}">` ,
149
151
map [string ]string {
150
- "GoGetImport" : composeGoGetImport ( ctx . Params ( ": username" ) , strings .TrimSuffix (ctx . Params ( ": reponame" ) , ".git" )),
151
- "CloneLink" : models .ComposeHTTPSCloneURL (ctx . Params ( ": username" ), ctx . Params ( ": reponame" ) ),
152
+ "GoGetImport" : ComposeGoGetImport ( username , strings .TrimSuffix (reponame , ".git" )),
153
+ "CloneLink" : models .ComposeHTTPSCloneURL (username , reponame ),
152
154
})))
153
155
}
154
156
@@ -216,7 +218,7 @@ func RepoIDAssignment() macaron.Handler {
216
218
// Check access.
217
219
if ctx .Repo .AccessMode == models .AccessModeNone {
218
220
if ctx .Query ("go-get" ) == "1" {
219
- earlyResponseForGoGetMeta (ctx )
221
+ EarlyResponseForGoGetMeta (ctx )
220
222
return
221
223
}
222
224
ctx .Handle (404 , "no access right" , err )
@@ -260,7 +262,7 @@ func RepoAssignment() macaron.Handler {
260
262
if err != nil {
261
263
if models .IsErrUserNotExist (err ) {
262
264
if ctx .Query ("go-get" ) == "1" {
263
- earlyResponseForGoGetMeta (ctx )
265
+ EarlyResponseForGoGetMeta (ctx )
264
266
return
265
267
}
266
268
ctx .Handle (404 , "GetUserByName" , nil )
@@ -282,7 +284,7 @@ func RepoAssignment() macaron.Handler {
282
284
RedirectToRepo (ctx , redirectRepoID )
283
285
} else if models .IsErrRepoRedirectNotExist (err ) {
284
286
if ctx .Query ("go-get" ) == "1" {
285
- earlyResponseForGoGetMeta (ctx )
287
+ EarlyResponseForGoGetMeta (ctx )
286
288
return
287
289
}
288
290
ctx .Handle (404 , "GetRepositoryByName" , nil )
@@ -315,7 +317,7 @@ func RepoAssignment() macaron.Handler {
315
317
// Check access.
316
318
if ctx .Repo .AccessMode == models .AccessModeNone {
317
319
if ctx .Query ("go-get" ) == "1" {
318
- earlyResponseForGoGetMeta (ctx )
320
+ EarlyResponseForGoGetMeta (ctx )
319
321
return
320
322
}
321
323
ctx .Handle (404 , "no access right" , err )
@@ -443,7 +445,7 @@ func RepoAssignment() macaron.Handler {
443
445
ctx .Data ["PullRequestCtx" ] = ctx .Repo .PullRequest
444
446
445
447
if ctx .Query ("go-get" ) == "1" {
446
- ctx .Data ["GoGetImport" ] = composeGoGetImport (owner .Name , repo .Name )
448
+ ctx .Data ["GoGetImport" ] = ComposeGoGetImport (owner .Name , repo .Name )
447
449
prefix := setting .AppURL + path .Join (owner .Name , repo .Name , "src" , ctx .Repo .BranchName )
448
450
ctx .Data ["GoDocDirectory" ] = prefix + "{/dir}"
449
451
ctx .Data ["GoDocFile" ] = prefix + "{/dir}/{file}#L{line}"
0 commit comments