@@ -124,21 +124,23 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
124
124
}
125
125
}
126
126
127
- // composeGoGetImport returns go-get-import meta content.
128
- func composeGoGetImport (owner , repo string ) string {
127
+ // ComposeGoGetImport returns go-get-import meta content.
128
+ func ComposeGoGetImport (owner , repo string ) string {
129
129
return path .Join (setting .Domain , setting .AppSubURL , owner , repo )
130
130
}
131
131
132
- // earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
132
+ // EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200
133
133
// if user does not have actual access to the requested repository,
134
134
// or the owner or repository does not exist at all.
135
135
// This is particular a workaround for "go get" command which does not respect
136
136
// .netrc file.
137
- func earlyResponseForGoGetMeta (ctx * Context ) {
137
+ func EarlyResponseForGoGetMeta (ctx * Context ) {
138
+ username := ctx .Params (":username" )
139
+ reponame := ctx .Params (":reponame" )
138
140
ctx .PlainText (200 , []byte (com .Expand (`<meta name="go-import" content="{GoGetImport} git {CloneLink}">` ,
139
141
map [string ]string {
140
- "GoGetImport" : composeGoGetImport ( ctx . Params ( ": username" ) , strings .TrimSuffix (ctx . Params ( ": reponame" ) , ".git" )),
141
- "CloneLink" : models .ComposeHTTPSCloneURL (ctx . Params ( ": username" ), ctx . Params ( ": reponame" ) ),
142
+ "GoGetImport" : ComposeGoGetImport ( username , strings .TrimSuffix (reponame , ".git" )),
143
+ "CloneLink" : models .ComposeHTTPSCloneURL (username , reponame ),
142
144
})))
143
145
}
144
146
@@ -206,7 +208,7 @@ func RepoIDAssignment() macaron.Handler {
206
208
// Check access.
207
209
if ctx .Repo .AccessMode == models .AccessModeNone {
208
210
if ctx .Query ("go-get" ) == "1" {
209
- earlyResponseForGoGetMeta (ctx )
211
+ EarlyResponseForGoGetMeta (ctx )
210
212
return
211
213
}
212
214
ctx .Handle (404 , "no access right" , err )
@@ -250,7 +252,7 @@ func RepoAssignment() macaron.Handler {
250
252
if err != nil {
251
253
if models .IsErrUserNotExist (err ) {
252
254
if ctx .Query ("go-get" ) == "1" {
253
- earlyResponseForGoGetMeta (ctx )
255
+ EarlyResponseForGoGetMeta (ctx )
254
256
return
255
257
}
256
258
ctx .Handle (404 , "GetUserByName" , nil )
@@ -272,7 +274,7 @@ func RepoAssignment() macaron.Handler {
272
274
RedirectToRepo (ctx , redirectRepoID )
273
275
} else if models .IsErrRepoRedirectNotExist (err ) {
274
276
if ctx .Query ("go-get" ) == "1" {
275
- earlyResponseForGoGetMeta (ctx )
277
+ EarlyResponseForGoGetMeta (ctx )
276
278
return
277
279
}
278
280
ctx .Handle (404 , "GetRepositoryByName" , nil )
@@ -305,7 +307,7 @@ func RepoAssignment() macaron.Handler {
305
307
// Check access.
306
308
if ctx .Repo .AccessMode == models .AccessModeNone {
307
309
if ctx .Query ("go-get" ) == "1" {
308
- earlyResponseForGoGetMeta (ctx )
310
+ EarlyResponseForGoGetMeta (ctx )
309
311
return
310
312
}
311
313
ctx .Handle (404 , "no access right" , err )
@@ -433,7 +435,7 @@ func RepoAssignment() macaron.Handler {
433
435
ctx .Data ["PullRequestCtx" ] = ctx .Repo .PullRequest
434
436
435
437
if ctx .Query ("go-get" ) == "1" {
436
- ctx .Data ["GoGetImport" ] = composeGoGetImport (owner .Name , repo .Name )
438
+ ctx .Data ["GoGetImport" ] = ComposeGoGetImport (owner .Name , repo .Name )
437
439
prefix := setting .AppURL + path .Join (owner .Name , repo .Name , "src" , ctx .Repo .BranchName )
438
440
ctx .Data ["GoDocDirectory" ] = prefix + "{/dir}"
439
441
ctx .Data ["GoDocFile" ] = prefix + "{/dir}/{file}#L{line}"
0 commit comments