mirror of
https://github.com/gogs/gogs.git
synced 2026-02-28 17:20:59 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
253b2bef4c | ||
|
|
1a051ae5f8 | ||
|
|
ca54cbd055 | ||
|
|
9044afa40f | ||
|
|
672625b55c | ||
|
|
98c65f319f |
11
.github/workflows/go.yml
vendored
11
.github/workflows/go.yml
vendored
@@ -1,8 +1,14 @@
|
||||
name: Go
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches:
|
||||
- main
|
||||
- 'release/**'
|
||||
paths:
|
||||
- '**.go'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.go'
|
||||
env:
|
||||
GOPROXY: "https://proxy.golang.org"
|
||||
|
||||
@@ -21,7 +27,7 @@ jobs:
|
||||
name: Test
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.14.x]
|
||||
go-version: [1.14.x, 1.15.x]
|
||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -45,4 +51,3 @@ jobs:
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
|
||||
48
CHANGELOG.md
48
CHANGELOG.md
@@ -2,13 +2,57 @@
|
||||
|
||||
All notable changes to Gogs are documented in this file.
|
||||
|
||||
## 0.13.0+dev (`master`)
|
||||
## 0.13.0+dev (`main`)
|
||||
|
||||
### Added
|
||||
|
||||
- An unlisted option is added when create or migrate a repository. Unlisted repositories are public but not being listed for users without direct access in the UI. [#5733](https://github.com/gogs/gogs/issues/5733)
|
||||
|
||||
### Changed
|
||||
|
||||
- The default branch has been changed to `main`. [#6285](https://github.com/gogs/gogs/pull/6285)
|
||||
- MSSQL as database backend is deprecated, installation page no longer shows it as an option. Existing installations and manually craft configuration file continue to work. [#6295](https://github.com/gogs/gogs/pull/6295)
|
||||
- Use [Task](https://github.com/go-task/task) as the default build tool for development. [#6297](https://github.com/gogs/gogs/pull/6297)
|
||||
|
||||
### Fixed
|
||||
|
||||
- _Regression:_ Pages are correctly rendered when requesting `?go-get=1` for subdirectories. [#6314](https://github.com/gogs/gogs/issues/6314)
|
||||
- _Regression:_ Submodule with a relative path is linked correctly. [#6319](https://github.com/gogs/gogs/issues/6319)
|
||||
- Backup can be processed when `--target` is specified on Windows. [#6339](https://github.com/gogs/gogs/issues/6339)
|
||||
- Commit message contains keywords look like an issue reference no longer fails the push entirely. [#6289](https://github.com/gogs/gogs/issues/6289)
|
||||
|
||||
### Removed
|
||||
|
||||
- ⚠️ Migrations before 0.12 are removed, installations not on 0.12 should upgrade to it to run the migrations and then upgrade to 0.13.
|
||||
- Configuration section `[mailer]` is no longer used.
|
||||
- Configuration section `[service]` is no longer used.
|
||||
- Configuration option `APP_NAME` is no longer used.
|
||||
- Configuration option `[security] REVERSE_PROXY_AUTHENTICATION_USER` is no longer used.
|
||||
- Configuration option `[database] PASSWD` is no longer used.
|
||||
- Configuration option `[auth] ACTIVE_CODE_LIVE_MINUTES` is no longer used.
|
||||
- Configuration option `[auth] RESET_PASSWD_CODE_LIVE_MINUTES` is no longer used.
|
||||
- Configuration option `[auth] ENABLE_CAPTCHA` is no longer used.
|
||||
- Configuration option `[auth] ENABLE_NOTIFY_MAIL` is no longer used.
|
||||
- Configuration option `[auth] REGISTER_EMAIL_CONFIRM` is no longer used.
|
||||
- Configuration option `[session] GC_INTERVAL_TIME` is no longer used.
|
||||
- Configuration option `[session] SESSION_LIFE_TIME` is no longer used.
|
||||
- Configuration option `[server] ROOT_URL` is no longer used.
|
||||
- Configuration option `[server] LANDING_PAGE` is no longer used.
|
||||
- Configuration option `[database] DB_TYPE` is no longer used.
|
||||
- Configuration option `[database] PASSWD` is no longer used.
|
||||
|
||||
## 0.12.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- The `updated_at` field is now correctly updated when updates an issue. [#6209](https://github.com/gogs/gogs/issues/6209)
|
||||
- Fixed a regression which created `login_source.cfg` column to have `VARCHAR(255)` instead of `TEXT` in MySQL. [#6280](https://github.com/gogs/gogs/issues/6280)
|
||||
|
||||
## 0.12.0
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Git LFS, you can read documentation for both [user](https://github.com/gogs/gogs/blob/master/docs/user/lfs.md) and [admin](https://github.com/gogs/gogs/blob/master/docs/admin/lfs.md). [#1322](https://github.com/gogs/gogs/issues/1322)
|
||||
- Support for Git LFS, you can read documentation for both [user](https://github.com/gogs/gogs/blob/main/docs/user/lfs.md) and [admin](https://github.com/gogs/gogs/blob/main/docs/admin/lfs.md). [#1322](https://github.com/gogs/gogs/issues/1322)
|
||||
- Allow admin to remove observers from the repository. [#5803](https://github.com/gogs/gogs/pull/5803)
|
||||
- Use `Last-Modified` HTTP header for raw files. [#5811](https://github.com/gogs/gogs/issues/5811)
|
||||
- Support syntax highlighting for SAS code files (i.e. `.r`, `.sas`, `.tex`, `.yaml`). [#5856](https://github.com/gogs/gogs/pull/5856)
|
||||
|
||||
2
go.mod
2
go.mod
@@ -51,7 +51,7 @@ require (
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/t-tiger/gorm-bulk-insert v1.3.0
|
||||
github.com/unknwon/cae v1.0.0
|
||||
github.com/unknwon/cae v1.0.2
|
||||
github.com/unknwon/com v1.0.1
|
||||
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6
|
||||
github.com/unknwon/paginater v0.0.0-20170405233947-45e5d631308e
|
||||
|
||||
5
go.sum
5
go.sum
@@ -266,6 +266,7 @@ github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUr
|
||||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -282,8 +283,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/t-tiger/gorm-bulk-insert v1.3.0 h1:9k7BaVEhw/3fsvh6GTOBwJ2RXk3asc5xs5m6hwozq20=
|
||||
github.com/t-tiger/gorm-bulk-insert v1.3.0/go.mod h1:ruDlk8xDl+8sX4bA7PQuYly9YEb3pbp1eP2LCyeRrFY=
|
||||
github.com/unknwon/cae v1.0.0 h1:i39lOFaBXZxhGjQOy/RNbi8uzettCs6OQxpR0xXohGU=
|
||||
github.com/unknwon/cae v1.0.0/go.mod h1:QaSeRctcea9fK6piJpAMCCPKxzJ01+xFcr2k1m3WRPU=
|
||||
github.com/unknwon/cae v1.0.2 h1:3L8/RCN1ARvD5quyNjU30EdvYkFbxBfnRcIBXugpHlg=
|
||||
github.com/unknwon/cae v1.0.2/go.mod h1:HqpmD2fVq9G1oGEXrXzbgIp51uJ29Hshv41n9ljm+AA=
|
||||
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
|
||||
github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
|
||||
github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
|
||||
|
||||
2
gogs.go
2
gogs.go
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
conf.App.Version = "0.12.1"
|
||||
conf.App.Version = "0.12.2"
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -611,7 +611,7 @@ func runWeb(c *cli.Context) error {
|
||||
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.MustBeNotBare, context.RepoRef(), repo.CompareDiff)
|
||||
}, ignSignIn, context.RepoAssignment())
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Get("", repo.Home)
|
||||
m.Get("", context.ServeGoGet(), repo.Home)
|
||||
m.Get("/stars", repo.Stars)
|
||||
m.Get("/watchers", repo.Watchers)
|
||||
}, ignSignIn, context.RepoAssignment(), context.RepoRef())
|
||||
@@ -659,7 +659,7 @@ func runWeb(c *cli.Context) error {
|
||||
lfs.RegisterRoutes(m.Router)
|
||||
})
|
||||
|
||||
m.Route("/*", "GET,POST,OPTIONS", repo.HTTPContexter(), repo.HTTP)
|
||||
m.Route("/*", "GET,POST,OPTIONS", context.ServeGoGet(), repo.HTTPContexter(), repo.HTTP)
|
||||
})
|
||||
|
||||
// ***************************
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -16,7 +15,6 @@ import (
|
||||
"github.com/go-macaron/csrf"
|
||||
"github.com/go-macaron/i18n"
|
||||
"github.com/go-macaron/session"
|
||||
"github.com/unknwon/com"
|
||||
"gopkg.in/macaron.v1"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
@@ -249,52 +247,6 @@ func Contexter() macaron.Handler {
|
||||
c.Data["Link"] = template.EscapePound(c.Link)
|
||||
c.Data["PageStartTime"] = time.Now()
|
||||
|
||||
// Quick responses appropriate go-get meta with status 200
|
||||
// regardless of if user have access to the repository,
|
||||
// or the repository does not exist at all.
|
||||
// This is particular a workaround for "go get" command which does not respect
|
||||
// .netrc file.
|
||||
if c.Query("go-get") == "1" {
|
||||
ownerName := c.Params(":username")
|
||||
repoName := c.Params(":reponame")
|
||||
branchName := "master"
|
||||
|
||||
owner, err := db.GetUserByName(ownerName)
|
||||
if err != nil {
|
||||
c.NotFoundOrError(err, "get user by name")
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := db.GetRepositoryByName(owner.ID, repoName)
|
||||
if err == nil && len(repo.DefaultBranch) > 0 {
|
||||
branchName = repo.DefaultBranch
|
||||
}
|
||||
|
||||
prefix := conf.Server.ExternalURL + path.Join(ownerName, repoName, "src", branchName)
|
||||
insecureFlag := ""
|
||||
if !strings.HasPrefix(conf.Server.ExternalURL, "https://") {
|
||||
insecureFlag = "--insecure "
|
||||
}
|
||||
c.PlainText(http.StatusOK, com.Expand(`<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="go-import" content="{GoGetImport} git {CloneLink}">
|
||||
<meta name="go-source" content="{GoGetImport} _ {GoDocDirectory} {GoDocFile}">
|
||||
</head>
|
||||
<body>
|
||||
go get {InsecureFlag}{GoGetImport}
|
||||
</body>
|
||||
</html>
|
||||
`, map[string]string{
|
||||
"GoGetImport": path.Join(conf.Server.URL.Host, conf.Server.Subpath, ownerName, repoName),
|
||||
"CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName),
|
||||
"GoDocDirectory": prefix + "{/dir}",
|
||||
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
|
||||
"InsecureFlag": insecureFlag,
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
if len(conf.HTTP.AccessControlAllowOrigin) > 0 {
|
||||
c.Header().Set("Access-Control-Allow-Origin", conf.HTTP.AccessControlAllowOrigin)
|
||||
c.Header().Set("'Access-Control-Allow-Credentials' ", "true")
|
||||
|
||||
62
internal/context/go_get.go
Normal file
62
internal/context/go_get.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db"
|
||||
)
|
||||
|
||||
// ServeGoGet does quick responses for appropriate go-get meta with status OK
|
||||
// regardless of whether the user has access to the repository, or the repository
|
||||
// does exist at all. This is particular a workaround for "go get" command which
|
||||
// does not respect .netrc file.
|
||||
func ServeGoGet() macaron.Handler {
|
||||
return func(c *macaron.Context) {
|
||||
if c.Query("go-get") != "1" {
|
||||
return
|
||||
}
|
||||
|
||||
ownerName := c.Params(":username")
|
||||
repoName := c.Params(":reponame")
|
||||
branchName := "master"
|
||||
|
||||
owner, err := db.Users.GetByUsername(ownerName)
|
||||
if err == nil {
|
||||
repo, err := db.Repos.GetByName(owner.ID, repoName)
|
||||
if err == nil && repo.DefaultBranch != "" {
|
||||
branchName = repo.DefaultBranch
|
||||
}
|
||||
}
|
||||
|
||||
prefix := conf.Server.ExternalURL + path.Join(ownerName, repoName, "src", branchName)
|
||||
insecureFlag := ""
|
||||
if !strings.HasPrefix(conf.Server.ExternalURL, "https://") {
|
||||
insecureFlag = "--insecure "
|
||||
}
|
||||
c.PlainText(http.StatusOK, []byte(com.Expand(`<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="go-import" content="{GoGetImport} git {CloneLink}">
|
||||
<meta name="go-source" content="{GoGetImport} _ {GoDocDirectory} {GoDocFile}">
|
||||
</head>
|
||||
<body>
|
||||
go get {InsecureFlag}{GoGetImport}
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
map[string]string{
|
||||
"GoGetImport": path.Join(conf.Server.URL.Host, conf.Server.Subpath, ownerName, repoName),
|
||||
"CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName),
|
||||
"GoDocDirectory": prefix + "{/dir}",
|
||||
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
|
||||
"InsecureFlag": insecureFlag,
|
||||
},
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,9 @@ var (
|
||||
IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"}
|
||||
IssueReopenKeywords = []string{"reopen", "reopens", "reopened"}
|
||||
|
||||
IssueCloseKeywordsPat = lazyregexp.New(assembleKeywordsPattern(IssueCloseKeywords))
|
||||
IssueReopenKeywordsPat = lazyregexp.New(assembleKeywordsPattern(IssueReopenKeywords))
|
||||
IssueReferenceKeywordsPat = lazyregexp.New(`(?i)(?:)(^| )\S+`)
|
||||
IssueCloseKeywordsPat = lazyregexp.New(assembleKeywordsPattern(IssueCloseKeywords))
|
||||
IssueReopenKeywordsPat = lazyregexp.New(assembleKeywordsPattern(IssueReopenKeywords))
|
||||
issueReferencePattern = lazyregexp.New(`(?i)(?:)(^| )\S*#\d+`)
|
||||
)
|
||||
|
||||
func assembleKeywordsPattern(words []string) string {
|
||||
@@ -321,8 +321,8 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
|
||||
c := commits[i]
|
||||
|
||||
refMarked := make(map[int64]bool)
|
||||
for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
|
||||
ref = ref[strings.IndexByte(ref, byte(' '))+1:]
|
||||
for _, ref := range issueReferencePattern.FindAllString(c.Message, -1) {
|
||||
ref = strings.TrimSpace(ref)
|
||||
ref = strings.TrimRightFunc(ref, issueIndexTrimRight)
|
||||
|
||||
if len(ref) == 0 {
|
||||
@@ -455,7 +455,7 @@ type CommitRepoActionOptions struct {
|
||||
Commits *PushCommits
|
||||
}
|
||||
|
||||
// CommitRepoAction adds new commit actio to the repository, and prepare corresponding webhooks.
|
||||
// CommitRepoAction adds new commit action to the repository, and prepare corresponding webhooks.
|
||||
func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
pusher, err := GetUserByName(opts.PusherName)
|
||||
if err != nil {
|
||||
|
||||
41
internal/db/action_test.go
Normal file
41
internal/db/action_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_issueReferencePattern(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
message string
|
||||
expStrings []string
|
||||
}{
|
||||
{
|
||||
name: "no match",
|
||||
message: "Hello world!",
|
||||
expStrings: nil,
|
||||
},
|
||||
{
|
||||
name: "contains issue numbers",
|
||||
message: "#123 is fixed, and #456 is WIP",
|
||||
expStrings: []string{"#123", " #456"},
|
||||
},
|
||||
{
|
||||
name: "contains full issue references",
|
||||
message: "#123 is fixed, and user/repo#456 is WIP",
|
||||
expStrings: []string{"#123", " user/repo#456"},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
strs := issueReferencePattern.FindAllString(test.message, -1)
|
||||
assert.Equal(t, test.expStrings, strs)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
type InvalidIssueReference struct {
|
||||
Ref string
|
||||
}
|
||||
|
||||
func IsInvalidIssueReference(err error) bool {
|
||||
_, ok := err.(InvalidIssueReference)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err InvalidIssueReference) Error() string {
|
||||
return fmt.Sprintf("invalid issue reference [ref: %s]", err.Ref)
|
||||
}
|
||||
@@ -817,12 +817,11 @@ func (ErrIssueNotExist) NotFound() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// GetIssueByRef returns an Issue specified by a GFM reference.
|
||||
// See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
|
||||
// GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123.
|
||||
func GetIssueByRef(ref string) (*Issue, error) {
|
||||
n := strings.IndexByte(ref, byte('#'))
|
||||
if n == -1 {
|
||||
return nil, errors.InvalidIssueReference{Ref: ref}
|
||||
return nil, ErrIssueNotExist{args: map[string]interface{}{"ref": ref}}
|
||||
}
|
||||
|
||||
index := com.StrTo(ref[n+1:]).MustInt64()
|
||||
|
||||
@@ -17,10 +17,21 @@ import (
|
||||
var scpSyntax = lazyregexp.New(`^([a-zA-Z0-9_]+@)?([a-zA-Z0-9._-]+):(.*)$`)
|
||||
|
||||
// InferSubmoduleURL returns the inferred external URL of the submodule at best effort.
|
||||
func InferSubmoduleURL(mod *git.Submodule) string {
|
||||
// The `baseURL` should be the URL of the current repository. If the submodule URL looks
|
||||
// like a relative path, it assumes that the submodule is another repository on the same
|
||||
// Gogs instance by appending it to the `baseURL` with the commit.
|
||||
func InferSubmoduleURL(baseURL string, mod *git.Submodule) string {
|
||||
if !strings.HasSuffix(baseURL, "/") {
|
||||
baseURL += "/"
|
||||
}
|
||||
|
||||
raw := strings.TrimSuffix(mod.URL, "/")
|
||||
raw = strings.TrimSuffix(raw, ".git")
|
||||
|
||||
if strings.HasPrefix(raw, "../") {
|
||||
return fmt.Sprintf("%s%s/commit/%s", baseURL, raw, mod.Commit)
|
||||
}
|
||||
|
||||
parsed, err := url.Parse(raw)
|
||||
if err != nil {
|
||||
// Try parse as SCP syntax again
|
||||
|
||||
@@ -41,6 +41,14 @@ func TestInferSubmoduleURL(t *testing.T) {
|
||||
},
|
||||
expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
|
||||
},
|
||||
{
|
||||
name: "relative path",
|
||||
submodule: &git.Submodule{
|
||||
URL: "../repo2.git",
|
||||
Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807",
|
||||
},
|
||||
expURL: "https://gogs.example.com/user/repo/../repo2/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
|
||||
},
|
||||
{
|
||||
name: "bad URL",
|
||||
submodule: &git.Submodule{
|
||||
@@ -52,7 +60,7 @@ func TestInferSubmoduleURL(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
assert.Equal(t, test.expURL, InferSubmoduleURL(test.submodule))
|
||||
assert.Equal(t, test.expURL, InferSubmoduleURL("https://gogs.example.com/user/repo", test.submodule))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
{{if .Submodule}}
|
||||
<td>
|
||||
<span class="octicon octicon-file-submodule"></span>
|
||||
<a href="{{InferSubmoduleURL .Submodule}}">{{.Entry.Name}} @ {{ShortSHA1 .Submodule.Commit}}</a>
|
||||
<a href="{{InferSubmoduleURL $.RepoLink .Submodule}}">{{.Entry.Name}} @ {{ShortSHA1 .Submodule.Commit}}</a>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="name">
|
||||
|
||||
Reference in New Issue
Block a user