From beb8d6fcd47a1a715d47a65b10daa8fe5e40e4d6 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 09:00:00 +0000
Subject: [PATCH 01/18] Add missing locale entries for oauth group claims
Signed-off-by: Andrew Thornton
---
options/locale/locale_en-US.ini | 3 +++
1 file changed, 3 insertions(+)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 3f180ddbecc06..95d58efd2e833 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -2526,6 +2526,9 @@ auths.oauth2_required_claim_name = Required Claim Name
auths.oauth2_required_claim_name_helper = Set this name to restrict login from this source to users with a claim with this name
auths.oauth2_required_claim_value = Required Claim Value
auths.oauth2_required_claim_value_helper = Set this value to restrict login from this source to users with a claim with this name and value
+auths.oauth2_group_claim_name = Claim name providing group names for this source. (Optional)
+auths.oauth2_admin_group = Group Claim value for administrator users. (Optional - requires claim name above)
+auths.oauth2_restricted_group = Group Claim value for restricted users. (Optional - requires claim name above)
auths.enable_auto_register = Enable Auto Registration
auths.sspi_auto_create_users = Automatically create users
auths.sspi_auto_create_users_helper = Allow SSPI auth method to automatically create new accounts for users that login for the first time
From f7c4de436e2a18dbe6e2b39c08a83908c1669e3a Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 09:28:19 +0000
Subject: [PATCH 02/18] Adjust branch links in feeds.tmpl - Fix #17943
Signed-off-by: Andrew Thornton
---
models/action.go | 16 ++++++++++++++++
templates/user/dashboard/feeds.tmpl | 16 ++++++----------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/models/action.go b/models/action.go
index da9e6776b138f..13ae4151ff3b9 100644
--- a/models/action.go
+++ b/models/action.go
@@ -23,6 +23,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
+ "code.gitea.io/gitea/modules/util"
"xorm.io/builder"
)
@@ -252,6 +253,21 @@ func (a *Action) GetBranch() string {
return strings.TrimPrefix(a.RefName, git.BranchPrefix)
}
+// GetRefLink returns the action's ref link.
+func (a *Action) GetRefLink() string {
+ switch {
+ case strings.HasPrefix(a.RefName, git.BranchPrefix):
+ return a.GetRepoLink() + "/src/branch/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.BranchPrefix))
+ case strings.HasPrefix(a.RefName, git.TagPrefix):
+ return a.GetRepoLink() + "/src/tag/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.TagPrefix))
+ case len(a.RefName) == 40 && git.SHAPattern.MatchString(a.RefName):
+ return a.GetRepoLink() + "/src/commit/" + a.RefName
+ default:
+ log.Warn("Unexpected ref type for GetBranchLink: %s in %d", a.RefName, a.RepoID)
+ return a.GetRepoLink() + "/src/branch/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.BranchPrefix))
+ }
+}
+
// GetTag returns the action's repository tag.
func (a *Action) GetTag() string {
return strings.TrimPrefix(a.RefName, git.TagPrefix)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index a2510f43ef4d2..f19b224f8a58a 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -17,11 +17,10 @@
{{else if eq .GetOpType 2}}
{{$.i18n.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 5}}
- {{ $branchLink := .GetBranch | PathEscapeSegments | Escape}}
{{if .Content}}
- {{$.i18n.Tr "action.commit_repo" (.GetRepoLink|Escape) $branchLink (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{else}}
- {{$.i18n.Tr "action.create_branch" (.GetRepoLink|Escape) $branchLink (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{end}}
{{else if eq .GetOpType 6}}
{{ $index := index .GetIssueInfos 0}}
@@ -32,8 +31,7 @@
{{else if eq .GetOpType 8}}
{{$.i18n.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 9}}
- {{ $tagLink := .GetTag | PathEscapeSegments | Escape}}
- {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) $tagLink (.ShortRepoPath|Escape) .GetTag | Str2html}}
+ {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) .GetTag | Str2html}}
{{else if eq .GetOpType 10}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_issue" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
@@ -59,10 +57,9 @@
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.delete_branch" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 18}}
- {{ $branchLink := .GetBranch | PathEscapeSegments}}
- {{$.i18n.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) $branchLink (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 19}}
- {{$.i18n.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 20}}
{{$.i18n.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 21}}
@@ -75,9 +72,8 @@
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_pull" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 24}}
- {{ $branchLink := .GetBranch | PathEscapeSegments | Escape}}
{{ $linkText := .Content | RenderEmoji }}
- {{$.i18n.Tr "action.publish_release" (.GetRepoLink|Escape) $branchLink (.ShortRepoPath|Escape) $linkText | Str2html}}
+ {{$.i18n.Tr "action.publish_release" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
{{else if eq .GetOpType 25}}
{{ $index := index .GetIssueInfos 0}}
{{ $reviewer := index .GetIssueInfos 1}}
From f555eb8bd8a47996a04039ad2ddf2b6a10a9e809 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 09:42:22 +0000
Subject: [PATCH 03/18] Make /issues match /pulls too - Fix #17983
Signed-off-by: Andrew Thornton
---
routers/web/web.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/routers/web/web.go b/routers/web/web.go
index 0d4d3bd90f4f9..44ac751c3150e 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -718,7 +718,7 @@ func RegisterRoutes(m *web.Route) {
}, context.RepoMustNotBeArchived(), reqRepoIssueReader)
// FIXME: should use different URLs but mostly same logic for comments of issue and pull request.
// So they can apply their own enable/disable logic on routers.
- m.Group("/issues", func() {
+ m.Group("/{type:issues|pulls}", func() {
m.Group("/{index}", func() {
m.Post("/title", repo.UpdateIssueTitle)
m.Post("/content", repo.UpdateIssueContent)
From c5befd981e0e7b6a0b62df234839736dbb2a316e Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 10:01:40 +0000
Subject: [PATCH 04/18] Fix panic on partial compares due to missing
PullRequestWorkInProgressPrefixes
Signed-off-by: Andrew Thornton
---
routers/web/repo/compare.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 8d08fec8fdb84..4f2d70807972d 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -685,6 +685,7 @@ func CompareDiff(ctx *context.Context) {
return
}
+ ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
ctx.Data["DirectComparison"] = ci.DirectComparison
ctx.Data["OtherCompareSeparator"] = ".."
ctx.Data["CompareSeparator"] = "..."
@@ -762,7 +763,6 @@ func CompareDiff(ctx *context.Context) {
ctx.Data["IsDiffCompare"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["RequireEasyMDE"] = true
- ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
setTemplateIfExists(ctx, pullRequestTemplateKey, nil, pullRequestTemplateCandidates)
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "comment")
From f6e6fa0495f0792e59c92d5bac5870a907a5a7cc Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 10:21:52 +0000
Subject: [PATCH 05/18] drop the warn
Signed-off-by: Andrew Thornton
---
models/action.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/models/action.go b/models/action.go
index 13ae4151ff3b9..26d05730c5f6d 100644
--- a/models/action.go
+++ b/models/action.go
@@ -263,7 +263,7 @@ func (a *Action) GetRefLink() string {
case len(a.RefName) == 40 && git.SHAPattern.MatchString(a.RefName):
return a.GetRepoLink() + "/src/commit/" + a.RefName
default:
- log.Warn("Unexpected ref type for GetBranchLink: %s in %d", a.RefName, a.RepoID)
+ // FIXME: we will just assume it's a branch - this was the old way - at some point we may want to enforce that there is always a ref here.
return a.GetRepoLink() + "/src/branch/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.BranchPrefix))
}
}
From 3af51edee43a5a554cec42c286eb994842a9a072 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 11:52:16 +0000
Subject: [PATCH 06/18] Handle nils in ColorFormat
---
models/org_team.go | 8 ++++++++
models/repo/repo.go | 7 +++++++
models/user/user.go | 6 ++++++
3 files changed, 21 insertions(+)
diff --git a/models/org_team.go b/models/org_team.go
index 3d4a2882c7981..7eac0f7bc52fe 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -114,6 +114,14 @@ func SearchTeam(opts *SearchTeamOptions) ([]*Team, int64, error) {
// ColorFormat provides a basic color format for a Team
func (t *Team) ColorFormat(s fmt.State) {
+ if t == nil {
+ log.ColorFprintf(s, "%d:%s (OrgID: %d) %-v",
+ log.NewColoredIDValue(0),
+ "",
+ log.NewColoredIDValue(0),
+ 0)
+ return
+ }
log.ColorFprintf(s, "%d:%s (OrgID: %d) %-v",
log.NewColoredIDValue(t.ID),
t.Name,
diff --git a/models/repo/repo.go b/models/repo/repo.go
index e5943b5a2d36c..dba7b50574490 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -173,6 +173,13 @@ func (repo *Repository) SanitizedOriginalURL() string {
// ColorFormat returns a colored string to represent this repo
func (repo *Repository) ColorFormat(s fmt.State) {
+ if repo == nil {
+ log.ColorFprintf(s, "%d:%s/%s",
+ log.NewColoredIDValue(0),
+ "",
+ "")
+ return
+ }
log.ColorFprintf(s, "%d:%s/%s",
log.NewColoredIDValue(repo.ID),
repo.OwnerName,
diff --git a/models/user/user.go b/models/user/user.go
index 80ddcdba37edf..d56a225d5f837 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -160,6 +160,12 @@ type SearchOrganizationsOptions struct {
// ColorFormat writes a colored string to identify this struct
func (u *User) ColorFormat(s fmt.State) {
+ if u == nil {
+ log.ColorFprintf(s, "%d:%s",
+ log.NewColoredIDValue(0),
+ log.NewColoredValue(""))
+ return
+ }
log.ColorFprintf(s, "%d:%s",
log.NewColoredIDValue(u.ID),
log.NewColoredValue(u.Name))
From 2d05ad4e8a460b13a473d374faff2874af8f4bff Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 12:08:03 +0000
Subject: [PATCH 07/18] Prevent hang in git cat-file if the repository is not a
valid repository
Signed-off-by: Andrew Thornton
---
modules/git/batch_reader.go | 11 +++++++++++
modules/git/repo_base_nogogit.go | 5 +++++
modules/git/repo_commit_nogogit.go | 5 ++++-
modules/indexer/code/bleve.go | 6 ++++++
modules/indexer/code/elastic_search.go | 5 +++++
services/pull/pull.go | 3 ++-
6 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go
index 71045adbc9bf4..2ed4c79662cfe 100644
--- a/modules/git/batch_reader.go
+++ b/modules/git/batch_reader.go
@@ -27,6 +27,17 @@ type WriteCloserError interface {
CloseWithError(err error) error
}
+func EnsureValidGitRepository(ctx context.Context, repoPath string) error {
+ stderr := strings.Builder{}
+ err := NewCommandContext(ctx, "rev-parse").
+ SetDescription(fmt.Sprintf("%s rev-parse [repo_path: %s]", GitExecutable, repoPath)).
+ RunInDirFullPipeline(repoPath, nil, &stderr, nil)
+ if err != nil {
+ return ConcatenateError(err, (&stderr).String())
+ }
+ return nil
+}
+
// CatFileBatchCheck opens git cat-file --batch-check in the provided repo and returns a stdin pipe, a stdout reader and cancel function
func CatFileBatchCheck(ctx context.Context, repoPath string) (WriteCloserError, *bufio.Reader, func()) {
batchStdinReader, batchStdinWriter := io.Pipe()
diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go
index 14a6cacb44702..e264fd4a14132 100644
--- a/modules/git/repo_base_nogogit.go
+++ b/modules/git/repo_base_nogogit.go
@@ -50,6 +50,11 @@ func OpenRepositoryCtx(ctx context.Context, repoPath string) (*Repository, error
return nil, errors.New("no such file or directory")
}
+ // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first!
+ if err := EnsureValidGitRepository(ctx, repoPath); err != nil {
+ return nil, err
+ }
+
repo := &Repository{
Path: repoPath,
tagCache: newObjectCache(),
diff --git a/modules/git/repo_commit_nogogit.go b/modules/git/repo_commit_nogogit.go
index d86e7d32680bd..c8cd7ec882a78 100644
--- a/modules/git/repo_commit_nogogit.go
+++ b/modules/git/repo_commit_nogogit.go
@@ -37,7 +37,10 @@ func (repo *Repository) ResolveReference(name string) (string, error) {
func (repo *Repository) GetRefCommitID(name string) (string, error) {
wr, rd, cancel := repo.CatFileBatchCheck(repo.Ctx)
defer cancel()
- _, _ = wr.Write([]byte(name + "\n"))
+ _, err := wr.Write([]byte(name + "\n"))
+ if err != nil {
+ return "", err
+ }
shaBs, _, _, err := ReadBatchLine(rd)
if IsErrNotExist(err) {
return "", ErrNotExist{name, ""}
diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go
index 1affdf73b046e..25cb8bf5c9a02 100644
--- a/modules/indexer/code/bleve.go
+++ b/modules/indexer/code/bleve.go
@@ -275,6 +275,12 @@ func (b *BleveIndexer) Index(repo *repo_model.Repository, sha string, changes *r
batch := gitea_bleve.NewFlushingBatch(b.indexer, maxBatchSize)
if len(changes.Updates) > 0 {
+ // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first!
+ if err := git.EnsureValidGitRepository(git.DefaultContext, repo.RepoPath()); err != nil {
+ log.Error("Unable to open git repo: %s for %-v: %v", repo.RepoPath(), repo, err)
+ return err
+ }
+
batchWriter, batchReader, cancel := git.CatFileBatch(git.DefaultContext, repo.RepoPath())
defer cancel()
diff --git a/modules/indexer/code/elastic_search.go b/modules/indexer/code/elastic_search.go
index bd5faf3b04635..169dffd78b441 100644
--- a/modules/indexer/code/elastic_search.go
+++ b/modules/indexer/code/elastic_search.go
@@ -247,6 +247,11 @@ func (b *ElasticSearchIndexer) addDelete(filename string, repo *repo_model.Repos
func (b *ElasticSearchIndexer) Index(repo *repo_model.Repository, sha string, changes *repoChanges) error {
reqs := make([]elastic.BulkableRequest, 0)
if len(changes.Updates) > 0 {
+ // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first!
+ if err := git.EnsureValidGitRepository(git.DefaultContext, repo.RepoPath()); err != nil {
+ log.Error("Unable to open git repo: %s for %-v: %v", repo.RepoPath(), repo, err)
+ return err
+ }
batchWriter, batchReader, cancel := git.CatFileBatch(git.DefaultContext, repo.RepoPath())
defer cancel()
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 3b127b8f1cf08..9103da07f4998 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -746,7 +746,8 @@ func GetIssuesLastCommitStatus(issues models.IssueList) (map[int64]*models.Commi
if !ok {
gitRepo, err = git.OpenRepository(issue.Repo.RepoPath())
if err != nil {
- return nil, err
+ log.Error("Cannot open git repository %-v for issue #%d[%d]. Error: %v", issue.Repo, issue.Index, issue.ID, err)
+ continue
}
gitRepos[issue.RepoID] = gitRepo
}
From 922fd8bdb4bfef1b657aa67d6187ec68934813bd Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 12:21:58 +0000
Subject: [PATCH 08/18] placate lint
Signed-off-by: Andrew Thornton
---
modules/git/batch_reader.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go
index 2ed4c79662cfe..7f7272c19ec7e 100644
--- a/modules/git/batch_reader.go
+++ b/modules/git/batch_reader.go
@@ -27,6 +27,9 @@ type WriteCloserError interface {
CloseWithError(err error) error
}
+// EnsureValidGitRepository runs git rev-parse in the repository path - thus ensuring that the repository is a valid repository.
+// Run before opening git cat-file.
+// This is needed otherwise the git cat-file will hang for invalid repositories.
func EnsureValidGitRepository(ctx context.Context, repoPath string) error {
stderr := strings.Builder{}
err := NewCommandContext(ctx, "rev-parse").
From c18fad2f90f147296e92660bb301a6e79e057562 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 12:52:29 +0000
Subject: [PATCH 09/18] and fix the issues/pulls links
Signed-off-by: Andrew Thornton
---
templates/user/dashboard/feeds.tmpl | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index f19b224f8a58a..00a75279f6ffc 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -24,32 +24,32 @@
{{end}}
{{else if eq .GetOpType 6}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.create_issue" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.create_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 7}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.create_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.create_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 8}}
{{$.i18n.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 9}}
{{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) .GetTag | Str2html}}
{{else if eq .GetOpType 10}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.comment_issue" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.comment_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 11}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.merge_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.merge_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 12}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.close_issue" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.close_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 13}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reopen_issue" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reopen_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 14}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.close_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.close_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 15}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reopen_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reopen_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 16}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
From 4231ccc0efdc4d63467e94fed8419cb20e253a74 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 12:55:17 +0000
Subject: [PATCH 10/18] and approve/reject links in feeds too
Signed-off-by: Andrew Thornton
---
templates/user/dashboard/feeds.tmpl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 00a75279f6ffc..008b63336d24f 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -64,10 +64,10 @@
{{$.i18n.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 21}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.approve_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.approve_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 22}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reject_pull_request" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reject_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 23}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_pull" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
From ac6ed7f0756bd6171c94259d8fc2d855dee70418 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 13:56:42 +0000
Subject: [PATCH 11/18] Add the missing directories to the testrepos
---
models/unittest/testdb.go | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go
index 8083c607e5d5c..912ff75d93c03 100644
--- a/models/unittest/testdb.go
+++ b/models/unittest/testdb.go
@@ -104,6 +104,26 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
fatalTestError("util.CopyDir: %v\n", err)
}
+ ownerDirs, err := os.ReadDir(pathToGiteaRoot)
+ if err != nil {
+ fatalTestError("unable to read the new repo root: %v\n", err)
+ }
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ if err != nil {
+ fatalTestError("unable to read the new repo root: %v\n", err)
+ }
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
+
exitStatus := m.Run()
if err = util.RemoveAll(repoRootPath); err != nil {
fatalTestError("util.RemoveAll: %v\n", err)
@@ -152,5 +172,22 @@ func PrepareTestEnv(t testing.TB) {
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
metaPath := filepath.Join(giteaRoot, "integrations", "gitea-repositories-meta")
assert.NoError(t, util.CopyDir(metaPath, setting.RepoRootPath))
+
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
+ assert.NoError(t, err)
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ assert.NoError(t, err)
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
+
base.SetupGiteaRoot() // Makes sure GITEA_ROOT is set
}
From 02b379f292ff168e81ec558c2e9440b2aa6f5539 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 14:03:09 +0000
Subject: [PATCH 12/18] fix broken pulls/issues links
Signed-off-by: Andrew Thornton
---
templates/user/dashboard/feeds.tmpl | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 008b63336d24f..5e6e956832acb 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -24,32 +24,32 @@
{{end}}
{{else if eq .GetOpType 6}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.create_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 7}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.create_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.create_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 8}}
{{$.i18n.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 9}}
{{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) .GetTag | Str2html}}
{{else if eq .GetOpType 10}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.comment_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 11}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.merge_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.merge_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 12}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.close_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.close_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 13}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reopen_issue" ((printf "%s/issues/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reopen_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 14}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.close_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.close_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 15}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reopen_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reopen_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 16}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
@@ -64,10 +64,10 @@
{{$.i18n.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 21}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.approve_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.approve_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 22}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.reject_pull_request" ((printf "%s/pulls/%d" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 23}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_pull" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
From 5dce707696a3a42e71443007de45934072a4b79c Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 14:35:38 +0000
Subject: [PATCH 13/18] fixup! Add the missing directories to the testrepos
---
models/unittest/testdb.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go
index 912ff75d93c03..c798dbefb1042 100644
--- a/models/unittest/testdb.go
+++ b/models/unittest/testdb.go
@@ -104,7 +104,7 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
fatalTestError("util.CopyDir: %v\n", err)
}
- ownerDirs, err := os.ReadDir(pathToGiteaRoot)
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
if err != nil {
fatalTestError("unable to read the new repo root: %v\n", err)
}
@@ -117,10 +117,10 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
fatalTestError("unable to read the new repo root: %v\n", err)
}
for _, repoDir := range repoDirs {
- _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
- _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
- _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
- _ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
}
}
From f428e120d84983b9ccdf39a6e227e463c163e05b Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 14:47:26 +0000
Subject: [PATCH 14/18] handle commment pull and review dismissed
Signed-off-by: Andrew Thornton
---
templates/user/dashboard/feeds.tmpl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 5e6e956832acb..4764a055be122 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -70,14 +70,14 @@
{{$.i18n.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 23}}
{{ $index := index .GetIssueInfos 0}}
- {{$.i18n.Tr "action.comment_pull" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 24}}
{{ $linkText := .Content | RenderEmoji }}
{{$.i18n.Tr "action.publish_release" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
{{else if eq .GetOpType 25}}
{{ $index := index .GetIssueInfos 0}}
{{ $reviewer := index .GetIssueInfos 1}}
- {{$.i18n.Tr "action.review_dismissed" (.GetRepoLink|Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}}
+ {{$.i18n.Tr "action.review_dismissed" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}}
{{end}}
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
From a4aac038244f67a3aa3cf6786223c8db35e5256d Mon Sep 17 00:00:00 2001
From: zeripath
Date: Wed, 15 Dec 2021 15:11:12 +0000
Subject: [PATCH 15/18] Update templates/user/dashboard/feeds.tmpl
Co-authored-by: Jimmy Praet
---
templates/user/dashboard/feeds.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 4764a055be122..76b1861cbe225 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -31,7 +31,7 @@
{{else if eq .GetOpType 8}}
{{$.i18n.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 9}}
- {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) .GetTag | Str2html}}
+ {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) .GetTag (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 10}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
From 5b3eba535161781279d03de1bfbc891adac672b0 Mon Sep 17 00:00:00 2001
From: zeripath
Date: Wed, 15 Dec 2021 15:21:30 +0000
Subject: [PATCH 16/18] Update templates/user/dashboard/feeds.tmpl
---
templates/user/dashboard/feeds.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 76b1861cbe225..7335a77c66c15 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -31,7 +31,7 @@
{{else if eq .GetOpType 8}}
{{$.i18n.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 9}}
- {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) .GetTag (.ShortRepoPath|Escape) | Str2html}}
+ {{$.i18n.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 10}}
{{ $index := index .GetIssueInfos 0}}
{{$.i18n.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
From 42de159572c5b1bdc0d8a40bd541dc23a13e0a50 Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 20:39:26 +0000
Subject: [PATCH 17/18] fix publish_release
Signed-off-by: Andrew Thornton
---
templates/user/dashboard/feeds.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 7335a77c66c15..c21ac337abde1 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -73,7 +73,7 @@
{{$.i18n.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 24}}
{{ $linkText := .Content | RenderEmoji }}
- {{$.i18n.Tr "action.publish_release" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
+ {{$.i18n.Tr "action.publish_release" (.GetRepoLink|Escape) ((printf "%s/release/tag/%s" .GetRepoLink .GetTag)|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
{{else if eq .GetOpType 25}}
{{ $index := index .GetIssueInfos 0}}
{{ $reviewer := index .GetIssueInfos 1}}
From 64b546c501544fefcbf21fb12b12c377feeb3a1a Mon Sep 17 00:00:00 2001
From: Andrew Thornton
Date: Wed, 15 Dec 2021 20:44:24 +0000
Subject: [PATCH 18/18] and ensure that all of the other places have the
objects directories too
Signed-off-by: Andrew Thornton
---
integrations/integration_test.go | 38 +++++++++++++++++++
integrations/migration-test/migration_test.go | 19 ++++++++++
models/migrations/migrations_test.go | 19 ++++++++++
3 files changed, 76 insertions(+)
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index 6dfc7350ded00..527d4b951ad27 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -255,6 +255,25 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
return deferFn
}
@@ -532,4 +551,23 @@ func resetFixtures(t *testing.T) {
assert.NoError(t, unittest.LoadFixtures())
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
}
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go
index 57354c39cb81f..2661704122502 100644
--- a/integrations/migration-test/migration_test.go
+++ b/integrations/migration-test/migration_test.go
@@ -61,6 +61,25 @@ func initMigrationTest(t *testing.T) func() {
assert.True(t, len(setting.RepoRootPath) != 0)
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
git.CheckLFSVersion()
setting.InitDBConfig()
diff --git a/models/migrations/migrations_test.go b/models/migrations/migrations_test.go
index 10ba3dde09597..ceef0954e12b1 100644
--- a/models/migrations/migrations_test.go
+++ b/models/migrations/migrations_test.go
@@ -207,6 +207,25 @@ func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.En
assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"),
setting.RepoRootPath))
+ ownerDirs, err := os.ReadDir(setting.RepoRootPath)
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, ownerDir := range ownerDirs {
+ if !ownerDir.Type().IsDir() {
+ continue
+ }
+ repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
+ if err != nil {
+ assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
+ }
+ for _, repoDir := range repoDirs {
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
+ _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
+ }
+ }
if err := deleteDB(); err != nil {
t.Errorf("unable to reset database: %v", err)