From 61ff3d9f97abdac81b7ced579bc87c3f95c7fecc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 4 May 2019 21:28:19 +0800 Subject: [PATCH 01/24] Add commit statuses reports on pull view --- models/{status.go => commit_status.go} | 112 ++++++++++-------- .../{status_test.go => commit_status_test.go} | 0 models/migrations/v87.go | 2 +- models/migrations/v88.go | 77 ++++++++++++ modules/repofiles/commit_status.go | 39 ++++++ routers/api/v1/repo/status.go | 4 +- routers/repo/pull.go | 16 +++ templates/repo/issue/view_content/pull.tmpl | 2 + templates/repo/pulls/status.tmpl | 32 +++++ 9 files changed, 235 insertions(+), 49 deletions(-) rename models/{status.go => commit_status.go} (78%) rename models/{status_test.go => commit_status_test.go} (100%) create mode 100644 models/migrations/v88.go create mode 100644 modules/repofiles/commit_status.go create mode 100644 templates/repo/pulls/status.tmpl diff --git a/models/status.go b/models/commit_status.go similarity index 78% rename from models/status.go rename to models/commit_status.go index 384f5693dcf56..79011e60e5616 100644 --- a/models/status.go +++ b/models/commit_status.go @@ -6,16 +6,14 @@ package models import ( "container/list" + "crypto/md5" "fmt" "strings" - "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - - "github.com/go-xorm/xorm" ) // CommitStatusState holds the state of a Status @@ -61,6 +59,7 @@ type CommitStatus struct { SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"` TargetURL string `xorm:"TEXT"` Description string `xorm:"TEXT"` + ContextHash string `xorm:"varchar(64) index"` Context string `xorm:"TEXT"` Creator *User `xorm:"-"` CreatorID int64 @@ -146,7 +145,7 @@ func GetLatestCommitStatus(repo *Repository, sha string, page int) ([]*CommitSta Table(&CommitStatus{}). Where("repo_id = ?", repo.ID).And("sha = ?", sha). Select("max( id ) as id"). - GroupBy("context").OrderBy("max( id ) desc").Find(&ids) + GroupBy("context_hash").OrderBy("max( id ) desc").Find(&ids) if err != nil { return nil, err } @@ -186,31 +185,31 @@ type NewCommitStatusOptions struct { CommitStatus *CommitStatus } -func newCommitStatus(sess *xorm.Session, opts NewCommitStatusOptions) error { - opts.CommitStatus.Description = strings.TrimSpace(opts.CommitStatus.Description) - opts.CommitStatus.Context = strings.TrimSpace(opts.CommitStatus.Context) - opts.CommitStatus.TargetURL = strings.TrimSpace(opts.CommitStatus.TargetURL) - opts.CommitStatus.SHA = opts.SHA - opts.CommitStatus.CreatorID = opts.Creator.ID - +// NewCommitStatus save commit statuses into database +func NewCommitStatus(opts NewCommitStatusOptions) error { if opts.Repo == nil { - return fmt.Errorf("newCommitStatus[nil, %s]: no repository specified", opts.SHA) + return fmt.Errorf("NewCommitStatus[nil, %s]: no repository specified", opts.SHA) } - opts.CommitStatus.RepoID = opts.Repo.ID - repoPath := opts.Repo.repoPath(sess) + repoPath := opts.Repo.RepoPath() if opts.Creator == nil { - return fmt.Errorf("newCommitStatus[%s, %s]: no user specified", repoPath, opts.SHA) + return fmt.Errorf("NewCommitStatus[%s, %s]: no user specified", repoPath, opts.SHA) } - gitRepo, err := git.OpenRepository(repoPath) - if err != nil { - return fmt.Errorf("OpenRepository[%s]: %v", repoPath, err) - } - if _, err := gitRepo.GetCommit(opts.SHA); err != nil { - return fmt.Errorf("GetCommit[%s]: %v", opts.SHA, err) + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { + return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %v", opts.Repo.ID, opts.Creator.ID, opts.SHA, err) } + opts.CommitStatus.Description = strings.TrimSpace(opts.CommitStatus.Description) + opts.CommitStatus.Context = strings.TrimSpace(opts.CommitStatus.Context) + opts.CommitStatus.TargetURL = strings.TrimSpace(opts.CommitStatus.TargetURL) + opts.CommitStatus.SHA = opts.SHA + opts.CommitStatus.CreatorID = opts.Creator.ID + opts.CommitStatus.RepoID = opts.Repo.ID + // Get the next Status Index var nextIndex int64 lastCommitStatus := &CommitStatus{ @@ -220,46 +219,40 @@ func newCommitStatus(sess *xorm.Session, opts NewCommitStatusOptions) error { has, err := sess.Desc("index").Limit(1).Get(lastCommitStatus) if err != nil { if err := sess.Rollback(); err != nil { - log.Error("newCommitStatus: sess.Rollback: %v", err) + log.Error("NewCommitStatus: sess.Rollback: %v", err) } - return fmt.Errorf("newCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) + return fmt.Errorf("NewCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) } if has { - log.Debug("newCommitStatus[%s, %s]: found", repoPath, opts.SHA) + log.Debug("NewCommitStatus[%s, %s]: found", repoPath, opts.SHA) nextIndex = lastCommitStatus.Index } opts.CommitStatus.Index = nextIndex + 1 - log.Debug("newCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index) + log.Debug("NewCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index) + + opts.CommitStatus.ContextHash = HashCommitStatusContext(opts.CommitStatus.Context) // Insert new CommitStatus if _, err = sess.Insert(opts.CommitStatus); err != nil { if err := sess.Rollback(); err != nil { - log.Error("newCommitStatus: sess.Rollback: %v", err) + log.Error("Insert CommitStatus: sess.Rollback: %v", err) } - return fmt.Errorf("newCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) + return fmt.Errorf("Insert CommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) } - return nil -} - -// NewCommitStatus creates a new CommitStatus given a bunch of parameters -// NOTE: All text-values will be trimmed from whitespaces. -// Requires: Repo, Creator, SHA -func NewCommitStatus(repo *Repository, creator *User, sha string, status *CommitStatus) error { - sess := x.NewSession() - defer sess.Close() - - if err := sess.Begin(); err != nil { - return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %v", repo.ID, creator.ID, sha, err) + exist, err := sess.Table("commit_status_context").Where("context_hash = ?", opts.CommitStatus.ContextHash).Exist() + if err != nil { + return fmt.Errorf("Check CommistStatusContext Exist failed: %v", err) } - - if err := newCommitStatus(sess, NewCommitStatusOptions{ - Repo: repo, - Creator: creator, - SHA: sha, - CommitStatus: status, - }); err != nil { - return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %v", repo.ID, creator.ID, sha, err) + if !exist { + if _, err = sess.Insert(&CommitStatusContext{ + RepoID: opts.Repo.ID, + ContextHash: opts.CommitStatus.ContextHash, + ContextLogo: "", + Context: opts.CommitStatus.Context, + }); err != nil { + return fmt.Errorf("Insert CommitStatusContext[%s, %s]: %v", repoPath, opts.SHA, err) + } } return sess.Commit() @@ -295,3 +288,28 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List } return newCommits } + +// HashCommitStatusContext hash context +func HashCommitStatusContext(context string) string { + return fmt.Sprintf("%x", md5.Sum([]byte(context))) +} + +// CommitStatusContext represents commit status context +type CommitStatusContext struct { + ID int64 + RepoID int64 `xorm:"index"` + ContextHash string `xorm:"varchar(40) unique"` + ContextLogo string `xorm:"TEXT"` + Context string `xorm:"TEXT"` + CreatedUnix util.TimeStamp `xorm:"created"` +} + +// FindRepoCommitStatusContexts find repository's commit status contexts +func FindRepoCommitStatusContexts(repoID int64) ([]string, error) { + var contexts = make([]string, 0, 3) + err := x.Where("repo_id = ?", repoID).Table("commit_status_context").Find(&contexts) + if err != nil { + return nil, err + } + return contexts, nil +} diff --git a/models/status_test.go b/models/commit_status_test.go similarity index 100% rename from models/status_test.go rename to models/commit_status_test.go diff --git a/models/migrations/v87.go b/models/migrations/v87.go index 94711ac669035..c8c7011a08a9e 100644 --- a/models/migrations/v87.go +++ b/models/migrations/v87.go @@ -1,4 +1,4 @@ -// Copyright 2019 Gitea. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. diff --git a/models/migrations/v88.go b/models/migrations/v88.go new file mode 100644 index 0000000000000..a1ec31e15a704 --- /dev/null +++ b/models/migrations/v88.go @@ -0,0 +1,77 @@ +// Copyright 2019 The Gitea 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 migrations + +import ( + "crypto/md5" + "fmt" + + "code.gitea.io/gitea/modules/util" + + "github.com/go-xorm/xorm" +) + +func hashContext(context string) string { + return fmt.Sprintf("%x", md5.Sum([]byte(context))) +} + +func addCommitStatusContext(x *xorm.Engine) error { + type CommitStatus struct { + ID int64 `xorm:"pk autoincr"` + ContextHash string `xorm:"varchar(40) index"` + Context string `xorm:"TEXT"` + } + + if err := x.Sync2(new(CommitStatus)); err != nil { + return err + } + + sess := x.NewSession() + defer sess.Close() + + var start = 0 + for { + var statuses = make([]*CommitStatus, 0, 100) + err := sess.OrderBy("id").Limit(100, start).Find(&statuses) + if err != nil { + return err + } + if len(statuses) == 0 { + break + } + + if err = sess.Begin(); err != nil { + return err + } + + for _, status := range statuses { + status.ContextHash = hashContext(status.Context) + if _, err := sess.ID(status.ID).Cols("context_hash").Update(status); err != nil { + return err + } + } + + if err := sess.Commit(); err != nil { + return err + } + + if len(statuses) < 100 { + break + } + + start += len(statuses) + } + + type CommitStatusContext struct { + ID int64 + RepoID int64 `xorm:"index"` + ContextHash string `xorm:"varchar(64) unique"` + ContextLogo string `xorm:"TEXT"` + Context string `xorm:"TEXT"` + CreatedUnix util.TimeStamp `xorm:"created"` + } + + return x.Sync2(new(CommitStatusContext)) +} diff --git a/modules/repofiles/commit_status.go b/modules/repofiles/commit_status.go new file mode 100644 index 0000000000000..2148ff463d6f2 --- /dev/null +++ b/modules/repofiles/commit_status.go @@ -0,0 +1,39 @@ +// Copyright 2019 The Gitea 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 repofiles + +import ( + "fmt" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/git" +) + +// CreateCommitStatus creates a new CommitStatus given a bunch of parameters +// NOTE: All text-values will be trimmed from whitespaces. +// Requires: Repo, Creator, SHA +func CreateCommitStatus(repo *models.Repository, creator *models.User, sha string, status *models.CommitStatus, isOAuth bool) error { + repoPath := repo.RepoPath() + + // confirm that commit is exist + gitRepo, err := git.OpenRepository(repoPath) + if err != nil { + return fmt.Errorf("OpenRepository[%s]: %v", repoPath, err) + } + if _, err := gitRepo.GetCommit(sha); err != nil { + return fmt.Errorf("GetCommit[%s]: %v", sha, err) + } + + if err := models.NewCommitStatus(models.NewCommitStatusOptions{ + Repo: repo, + Creator: creator, + SHA: sha, + CommitStatus: status, + }); err != nil { + return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %v", repo.ID, creator.ID, sha, err) + } + + return nil +} diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 487e62c91d1f4..1f9d51f76e61d 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/repofiles" api "code.gitea.io/gitea/modules/structs" ) @@ -57,7 +58,8 @@ func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) { Description: form.Description, Context: form.Context, } - if err := models.NewCommitStatus(ctx.Repo.Repository, ctx.User, sha, status); err != nil { + isOAuthToken := ctx.Data["IsApiToken"] == true + if err := repofiles.CreateCommitStatus(ctx.Repo.Repository, ctx.User, sha, status, isOAuthToken); err != nil { ctx.Error(500, "NewCommitStatus", err) return } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 36b0d047b1019..9e630300b4cc9 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -329,6 +329,22 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare } } + sha, err := headGitRepo.GetBranchCommitID(pull.HeadBranch) + if err != nil { + ctx.ServerError("GetBranchCommitID", err) + return nil + } + + commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0) + if err != nil { + ctx.ServerError("GetLatestCommitStatus", err) + return nil + } + if len(commitStatuses) > 0 { + ctx.Data["LatestCommitStatuses"] = commitStatuses + ctx.Data["LatestCommitStatus"] = models.CalcCommitStatus(commitStatuses) + } + if pull.HeadRepo == nil || !headGitRepo.IsBranchExist(pull.HeadBranch) { ctx.Data["IsPullRequestBroken"] = true ctx.Data["HeadTarget"] = "deleted" diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 73c4179080003..f9c1fe70510fb 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -46,6 +46,8 @@ {{else}}red{{end}}">
+ {{template "repo/pulls/status" .}} + {{if .Issue.PullRequest.HasMerged}}
{{$.i18n.Tr "repo.pulls.has_merged"}} diff --git a/templates/repo/pulls/status.tmpl b/templates/repo/pulls/status.tmpl new file mode 100644 index 0000000000000..d7b0dd8e84cd3 --- /dev/null +++ b/templates/repo/pulls/status.tmpl @@ -0,0 +1,32 @@ +{{if $.LatestCommitStatus}} +
+ {{if eq .LatestCommitStatus.State "pending"}} + {{$.i18n.Tr "repo.pulls.status_checking"}} + {{else if eq .LatestCommitStatus.State "success"}} + {{$.i18n.Tr "repo.pulls.status_checks_success"}} + {{else if eq .LatestCommitStatus.State "error"}} + {{$.i18n.Tr "repo.pulls.status_checks_error"}} + {{else}} + {{$.i18n.Tr "repo.pulls.status_checking"}} + {{end}} +
+
+ {{range $.LatestCommitStatuses}} +
+ + {{if eq .State "pending"}} + + {{else if eq .State "success"}} + + {{else if eq .State "error"}} + + {{else}} + + {{end}} + + + {{if .TargetURL}}{{end}}{{.Context}} - {{.Description}}{{if .TargetURL}}{{end}} + +
+ {{end}} +{{end}} \ No newline at end of file From 906b92923e624af9f5c754a8cb467892663cea61 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 4 May 2019 21:37:36 +0800 Subject: [PATCH 02/24] Add some translations --- options/locale/locale_en-US.ini | 3 +++ templates/repo/pulls/status.tmpl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index acaa98c3a2264..815903d94c62f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -981,6 +981,9 @@ pulls.rebase_merge_commit_pull_request = Rebase and Merge (--no-ff) pulls.squash_merge_pull_request = Squash and Merge pulls.invalid_merge_option = You cannot use this merge option for this pull request. pulls.open_unmerged_pull_exists = `You cannot perform a reopen operation because there is a pending pull request (#%d) with identical properties.` +pulls.status_checking = Some checks are pending +pulls.status_checks_success = All checks were successful +pulls.status_checks_error = Some checks were not successful milestones.new = New Milestone milestones.open_tab = %d Open diff --git a/templates/repo/pulls/status.tmpl b/templates/repo/pulls/status.tmpl index d7b0dd8e84cd3..d28a4a1f15c5c 100644 --- a/templates/repo/pulls/status.tmpl +++ b/templates/repo/pulls/status.tmpl @@ -1,5 +1,5 @@ {{if $.LatestCommitStatus}} -
+
{{if eq .LatestCommitStatus.State "pending"}} {{$.i18n.Tr "repo.pulls.status_checking"}} {{else if eq .LatestCommitStatus.State "success"}} From 750c1b5eea54340c664db25bdb91968557d9ede0 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 20 May 2019 14:16:11 +0800 Subject: [PATCH 03/24] improve the UI --- templates/repo/issue/view_content/pull.tmpl | 5 ++--- templates/repo/pulls/status.tmpl | 25 ++++++--------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index f9c1fe70510fb..e3135de1308af 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -45,9 +45,8 @@ {{else if .Issue.PullRequest.CanAutoMerge}}green {{else}}red{{end}}">
-
- {{template "repo/pulls/status" .}} - + {{template "repo/pulls/status" .}} +
{{if .Issue.PullRequest.HasMerged}}
{{$.i18n.Tr "repo.pulls.has_merged"}} diff --git a/templates/repo/pulls/status.tmpl b/templates/repo/pulls/status.tmpl index d28a4a1f15c5c..e1401aa8bb83a 100644 --- a/templates/repo/pulls/status.tmpl +++ b/templates/repo/pulls/status.tmpl @@ -1,6 +1,6 @@ {{if $.LatestCommitStatus}} -
- {{if eq .LatestCommitStatus.State "pending"}} +
+ {{if eq .LatestCommitStatus.State "pending"}} {{$.i18n.Tr "repo.pulls.status_checking"}} {{else if eq .LatestCommitStatus.State "success"}} {{$.i18n.Tr "repo.pulls.status_checks_success"}} @@ -10,23 +10,12 @@ {{$.i18n.Tr "repo.pulls.status_checking"}} {{end}}
-
+ {{range $.LatestCommitStatuses}} -
- - {{if eq .State "pending"}} - - {{else if eq .State "success"}} - - {{else if eq .State "error"}} - - {{else}} - - {{end}} - - - {{if .TargetURL}}{{end}}{{.Context}} - {{.Description}}{{if .TargetURL}}{{end}} - +
+ {{template "repo/commit_status" .}} + {{.Context}} {{.Description}} +
{{if .TargetURL}}Details{{end}}
{{end}} {{end}} \ No newline at end of file From 9a2f62a3653a7611be7be6c556b0bf8f1a75ce82 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 20 May 2019 17:18:07 +0800 Subject: [PATCH 04/24] fix fmt --- routers/api/v1/repo/status.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 1f9d51f76e61d..0117536b184a2 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -142,6 +142,7 @@ func getCommitStatuses(ctx *context.APIContext, sha string) { statuses, err := models.GetCommitStatuses(repo, sha, page) if err != nil { ctx.Error(500, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, page, err)) + return } apiStatuses := make([]*api.Status, 0, len(statuses)) From d832ed1187b2fd465ca6b9ba9688e82293cc00fc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 21 May 2019 15:44:20 +0800 Subject: [PATCH 05/24] fix tests --- models/commit_status.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/commit_status.go b/models/commit_status.go index 79011e60e5616..144f6950e8aec 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -313,3 +313,7 @@ func FindRepoCommitStatusContexts(repoID int64) ([]string, error) { } return contexts, nil } + +func init() { + tables = append(tables, new(CommitStatusContext)) +} From 1a6cef2fb838837ccc3b765265d918f54c245a38 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 21 May 2019 17:31:21 +0800 Subject: [PATCH 06/24] add a new test git repo to fix tests --- .../user1/repo1.git/HEAD | 1 + .../user1/repo1.git/config | 4 + .../user1/repo1.git/description | 1 + .../repo1.git/hooks/applypatch-msg.sample | 15 ++ .../user1/repo1.git/hooks/commit-msg.sample | 24 +++ .../user1/repo1.git/hooks/post-receive | 7 + .../repo1.git/hooks/post-receive.d/gitea | 2 + .../user1/repo1.git/hooks/post-update.sample | 8 + .../repo1.git/hooks/pre-applypatch.sample | 14 ++ .../user1/repo1.git/hooks/pre-commit.sample | 49 +++++ .../user1/repo1.git/hooks/pre-push.sample | 53 ++++++ .../user1/repo1.git/hooks/pre-rebase.sample | 169 ++++++++++++++++++ .../user1/repo1.git/hooks/pre-receive | 7 + .../user1/repo1.git/hooks/pre-receive.d/gitea | 2 + .../repo1.git/hooks/prepare-commit-msg.sample | 36 ++++ .../user1/repo1.git/hooks/update | 7 + .../user1/repo1.git/hooks/update.d/gitea | 2 + .../user1/repo1.git/hooks/update.sample | 128 +++++++++++++ .../user1/repo1.git/info/exclude | 6 + .../user1/repo1.git/info/refs | 1 + .../15/20e879c0d3943e86ae59a7807693e1f137959b | Bin 0 -> 58 bytes .../2a/2f1d4670728a2e10049e345bd7a276468beab6 | Bin 0 -> 54 bytes .../3d/d8fc8ea15806b347b52a2b7f235536155d6ccd | Bin 0 -> 54 bytes .../4b/4851ad51df6a7d9f25c979345979eaeb5b349f | Bin 0 -> 42 bytes .../65/f1bf27bc3bf70f64657658635e66094edbcb4d | Bin 0 -> 150 bytes .../b5/62b5d871d57f359b6bddbf0c2233addd2de5bb | Bin 0 -> 823 bytes .../user1/repo1.git/objects/info/packs | 1 + .../user1/repo1.git/refs/heads/DefaultBranch | 1 + .../user1/repo1.git/refs/heads/branch2 | 1 + .../user1/repo1.git/refs/heads/develop | 1 + .../user1/repo1.git/refs/heads/feature/1 | 1 + .../user1/repo1.git/refs/heads/master | 1 + .../user1/repo1.git/refs/tags/v1.1 | 1 + models/fixtures/pull_request.yml | 4 +- models/fixtures/repository.yml | 13 ++ 35 files changed, 558 insertions(+), 2 deletions(-) create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/HEAD create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/config create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/description create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea create mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/info/exclude create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/info/refs create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/65/f1bf27bc3bf70f64657658635e66094edbcb4d create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/b5/62b5d871d57f359b6bddbf0c2233addd2de5bb create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/info/packs create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/DefaultBranch create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/branch2 create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/develop create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/feature/1 create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/master create mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/tags/v1.1 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/HEAD b/integrations/gitea-repositories-meta/user1/repo1.git/HEAD new file mode 100644 index 0000000000000..cb089cd89a7d7 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/config b/integrations/gitea-repositories-meta/user1/repo1.git/config new file mode 100644 index 0000000000000..07d359d07cf1e --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/description b/integrations/gitea-repositories-meta/user1/repo1.git/description new file mode 100644 index 0000000000000..498b267a8c781 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample new file mode 100755 index 0000000000000..a5d7b84a67345 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample new file mode 100755 index 0000000000000..b58d1184a9d43 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive new file mode 100755 index 0000000000000..4b3d452abcce2 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/post-receive.d"`; do + sh "$SHELL_FOLDER/post-receive.d/$i" +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea new file mode 100755 index 0000000000000..1c70c91d74527 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample new file mode 100755 index 0000000000000..ec17ec1939b7c --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample new file mode 100755 index 0000000000000..4142082bcb939 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample new file mode 100755 index 0000000000000..68d62d5446d96 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample new file mode 100755 index 0000000000000..6187dbf4390fc --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample new file mode 100755 index 0000000000000..33730ca647cb2 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive new file mode 100755 index 0000000000000..412701305369c --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/pre-receive.d"`; do + sh "$SHELL_FOLDER/pre-receive.d/$i" +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea new file mode 100755 index 0000000000000..3b2c4c2e04b28 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000000000..f093a02ec4991 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update new file mode 100755 index 0000000000000..c186fe4a18b0f --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/update.d"`; do + sh "$SHELL_FOLDER/update.d/$i" $1 $2 $3 +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea new file mode 100755 index 0000000000000..14b7b0091a23d --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample new file mode 100755 index 0000000000000..80ba94135cc37 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude b/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude new file mode 100644 index 0000000000000..a5196d1be8fb5 --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/info/refs b/integrations/gitea-repositories-meta/user1/repo1.git/info/refs new file mode 100644 index 0000000000000..ca1df85e2ebfb --- /dev/null +++ b/integrations/gitea-repositories-meta/user1/repo1.git/info/refs @@ -0,0 +1 @@ +65f1bf27bc3bf70f64657658635e66094edbcb4d refs/heads/master diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b b/integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b new file mode 100644 index 0000000000000000000000000000000000000000..754a83e0cd9cdfb4340dd470b9f6754980631b21 GIT binary patch literal 58 zcmV-A0LA}!0ZYosPf{>7Wl&ZqN-fAYR7lG&%1%vDNGrpF literal 0 HcmV?d00001 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 b/integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 new file mode 100644 index 0000000000000000000000000000000000000000..0994add2c8a420ba89b9a239de84741d4d00ee02 GIT binary patch literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx2y%6F@paY9O=0l%2wWR@KdW}W>d8uz$jVo* MqfO=m05RYX?j~gyApigX literal 0 HcmV?d00001 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd b/integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd new file mode 100644 index 0000000000000000000000000000000000000000..379ee0da3a23da21b44b51259619053dbdef4c58 GIT binary patch literal 54 zcmb%v7rOCc0q7S-{K(sSa& zkkbhiI`12U*27++lwz~nt#W~Lz0(ZW%yS%}3Kf0bq)P96vj0l1tFo_f7S z=HHwE1gOK)M^jZzS5;)yrn$5^TPTo%)*~@z_q0mI`M|nw$oH1od>(5^t9tni|K$XL z{E(bgN;#4`$M&>G4`{Yd0#e5DYQx4*7$vo9-cKrHP$<+IHuq}eNa-(2bj68D08X~5 zAiJe>0t+ltb{%g4SzTi{8e zl-*;(RZ9+}r>(d@th9G{I`Wo2Hm+b$c){TkxVpxv?Pd(QkJOZ@*=Gd_z{8%gZm*eB z;r>*Q_WDxyT`1yXDacbbv)p{d+vX;&XU)u~&SGD)v$|3!a*bfQWdyLiHs`KkjJ4Y( z(J(UJX%G)+XCkp_YIE>=M`UulJ5n=>;Y6|GV$gLfcx1-)lU5PHe3v2W`MmD=?8ba9 z`&gfQ<0X$jIOM~7@Wl+jj08wZKfVV0p0Lr(;!b

X4thi6>FA(}kLBf~~suR9?^YiTYMOt>8bMmms=l7o^9&z)Q6wh^$SYwIHp3nJ^sA%5<@ ztM?!6cz*J3{b(dNrH08!^+^7W0KW; Date: Tue, 21 May 2019 17:38:20 +0800 Subject: [PATCH 07/24] fix bug when headRepo or headBranch missing --- routers/repo/pull.go | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 9e630300b4cc9..4c377bb3643e7 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -321,31 +321,37 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare setMergeTarget(ctx, pull) var headGitRepo *git.Repository + var headBranchExist bool + // HeadRepo may be missing if pull.HeadRepo != nil { headGitRepo, err = git.OpenRepository(pull.HeadRepo.RepoPath()) if err != nil { ctx.ServerError("OpenRepository", err) return nil } - } - sha, err := headGitRepo.GetBranchCommitID(pull.HeadBranch) - if err != nil { - ctx.ServerError("GetBranchCommitID", err) - return nil - } + headBranchExist = headGitRepo.IsBranchExist(pull.HeadBranch) - commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0) - if err != nil { - ctx.ServerError("GetLatestCommitStatus", err) - return nil - } - if len(commitStatuses) > 0 { - ctx.Data["LatestCommitStatuses"] = commitStatuses - ctx.Data["LatestCommitStatus"] = models.CalcCommitStatus(commitStatuses) + if headBranchExist { + sha, err := headGitRepo.GetBranchCommitID(pull.HeadBranch) + if err != nil { + ctx.ServerError("GetBranchCommitID", err) + return nil + } + + commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0) + if err != nil { + ctx.ServerError("GetLatestCommitStatus", err) + return nil + } + if len(commitStatuses) > 0 { + ctx.Data["LatestCommitStatuses"] = commitStatuses + ctx.Data["LatestCommitStatus"] = models.CalcCommitStatus(commitStatuses) + } + } } - if pull.HeadRepo == nil || !headGitRepo.IsBranchExist(pull.HeadBranch) { + if pull.HeadRepo == nil || !headBranchExist { ctx.Data["IsPullRequestBroken"] = true ctx.Data["HeadTarget"] = "deleted" ctx.Data["NumCommits"] = 0 From b250b5da6f992c9a8d783c442be4816005b05d9b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 22 May 2019 08:13:10 +0800 Subject: [PATCH 08/24] fix tests --- models/fixtures/user.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index ed60e7f5eab06..9f8f81a4ee7a9 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -12,7 +12,7 @@ is_admin: true avatar: avatar1 avatar_email: user1@example.com - num_repos: 0 + num_repos: 1 is_active: true - From 020ffa5627448b78d2694f4232fc0e5a6325042d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 May 2019 10:03:54 +0800 Subject: [PATCH 09/24] fix tests --- models/fixtures/issue.yml | 11 +++++++++++ models/fixtures/pull_request.yml | 16 +++++++++++++++- models/fixtures/repository.yml | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/models/fixtures/issue.yml b/models/fixtures/issue.yml index 01bd8b86f6aa1..7c39c1197367c 100644 --- a/models/fixtures/issue.yml +++ b/models/fixtures/issue.yml @@ -86,3 +86,14 @@ created_unix: 946684830 updated_unix: 978307200 +- + id: 8 + repo_id: 1 + index: 5 + poster_id: 1 + name: pr2 + content: a pull request + is_closed: false + is_pull: true + created_unix: 946684820 + updated_unix: 978307180 \ No newline at end of file diff --git a/models/fixtures/pull_request.yml b/models/fixtures/pull_request.yml index 5349df9aa85a9..da9b9db3669b6 100644 --- a/models/fixtures/pull_request.yml +++ b/models/fixtures/pull_request.yml @@ -19,10 +19,24 @@ status: 2 # mergable issue_id: 3 index: 3 + head_repo_id: 1 + base_repo_id: 1 + head_user_name: user1 + head_branch: branch2 + base_branch: master + merge_base: fedcba9876543210 + has_merged: false + +- + id: 3 + type: 0 # gitea pull request + status: 2 # mergable + issue_id: 8 + index: 4 head_repo_id: 42 base_repo_id: 1 head_user_name: user1 head_branch: branch2 base_branch: master merge_base: 65f1bf27bc3bf70f - has_merged: false + has_merged: false \ No newline at end of file diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 134aefe2c466a..e3c455762433e 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -6,7 +6,7 @@ is_private: false num_issues: 2 num_closed_issues: 1 - num_pulls: 2 + num_pulls: 3 num_closed_pulls: 0 num_milestones: 3 num_closed_milestones: 1 From 33343b0955102b50a23987e45c4b1586a4251ec7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 6 Jun 2019 13:56:47 +0800 Subject: [PATCH 10/24] fix consistency --- models/fixtures/repository.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index e3c455762433e..64e58e57a67c9 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -11,6 +11,7 @@ num_milestones: 3 num_closed_milestones: 1 num_watches: 3 + num_forks: 1 - id: 2 From 11e79eeeab5bded3327a494375970369f2318492 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 9 Jun 2019 17:14:13 +0800 Subject: [PATCH 11/24] fix tests --- models/repo_list_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 645de2a59a4df..b80def5dfcb48 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -147,10 +147,10 @@ func TestSearchRepositoryByName(t *testing.T) { count: 14}, {name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true}, - count: 21}, + count: 22}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, - count: 27}, + count: 28}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName", opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, count: 15}, @@ -159,7 +159,7 @@ func TestSearchRepositoryByName(t *testing.T) { count: 13}, {name: "AllPublic/PublicRepositoriesOfOrganization", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse}, - count: 21}, + count: 22}, } for _, testCase := range testCases { From d0ff984817aec91d8af88db75826315ac3d256da Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 00:03:44 +0800 Subject: [PATCH 12/24] fix tests --- integrations/api_repo_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 8dedfd1ae0d44..60fe4a3649576 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -70,9 +70,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50&private=false", expectedResults: expectedResults{ - nil: {count: 21}, - user: {count: 21}, - user2: {count: 21}}, + nil: {count: 22}, + user: {count: 22}, + user2: {count: 22}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10&private=false", expectedResults: expectedResults{ nil: {count: 10}, From 06d76f0f492d301445048c3dde0ca2f64c6c0c0f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 10:02:34 +0800 Subject: [PATCH 13/24] change the test repo --- .../user1/repo1.git/HEAD | 1 - .../user1/repo1.git/config | 4 - .../user1/repo1.git/description | 1 - .../repo1.git/hooks/applypatch-msg.sample | 15 -- .../user1/repo1.git/hooks/commit-msg.sample | 24 --- .../user1/repo1.git/hooks/post-receive | 7 - .../repo1.git/hooks/post-receive.d/gitea | 2 - .../user1/repo1.git/hooks/post-update.sample | 8 - .../repo1.git/hooks/pre-applypatch.sample | 14 -- .../user1/repo1.git/hooks/pre-commit.sample | 49 ----- .../user1/repo1.git/hooks/pre-push.sample | 53 ------ .../user1/repo1.git/hooks/pre-rebase.sample | 169 ------------------ .../user1/repo1.git/hooks/pre-receive | 7 - .../user1/repo1.git/hooks/pre-receive.d/gitea | 2 - .../repo1.git/hooks/prepare-commit-msg.sample | 36 ---- .../user1/repo1.git/hooks/update | 7 - .../user1/repo1.git/hooks/update.d/gitea | 2 - .../user1/repo1.git/hooks/update.sample | 128 ------------- .../user1/repo1.git/info/exclude | 6 - .../user1/repo1.git/info/refs | 1 - .../15/20e879c0d3943e86ae59a7807693e1f137959b | Bin 58 -> 0 bytes .../2a/2f1d4670728a2e10049e345bd7a276468beab6 | Bin 54 -> 0 bytes .../3d/d8fc8ea15806b347b52a2b7f235536155d6ccd | Bin 54 -> 0 bytes .../4b/4851ad51df6a7d9f25c979345979eaeb5b349f | Bin 42 -> 0 bytes .../65/f1bf27bc3bf70f64657658635e66094edbcb4d | Bin 150 -> 0 bytes .../b5/62b5d871d57f359b6bddbf0c2233addd2de5bb | Bin 823 -> 0 bytes .../user1/repo1.git/objects/info/packs | 1 - .../user1/repo1.git/refs/heads/DefaultBranch | 1 - .../user1/repo1.git/refs/heads/branch2 | 1 - .../user1/repo1.git/refs/heads/develop | 1 - .../user1/repo1.git/refs/heads/feature/1 | 1 - .../user1/repo1.git/refs/heads/master | 1 - .../user1/repo1.git/refs/tags/v1.1 | 1 - .../0a/bcb056019adb8336cf9db3ad9d9cf80cd4b141 | Bin 0 -> 818 bytes .../75/d1afd00e111c8dbd9e3d96a27b431ac5ae6d74 | Bin 0 -> 44 bytes .../ed/447543e0c85d628b91f7f466f4921908f4c5ea | Bin 0 -> 54 bytes .../user13/repo11.git/refs/heads/branch2 | 1 + models/fixtures/issue.yml | 4 +- models/fixtures/pull_request.yml | 8 +- models/fixtures/repository.yml | 4 +- 40 files changed, 9 insertions(+), 551 deletions(-) delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/HEAD delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/config delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/description delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/info/exclude delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/info/refs delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/65/f1bf27bc3bf70f64657658635e66094edbcb4d delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/b5/62b5d871d57f359b6bddbf0c2233addd2de5bb delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/objects/info/packs delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/DefaultBranch delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/branch2 delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/develop delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/feature/1 delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/heads/master delete mode 100644 integrations/gitea-repositories-meta/user1/repo1.git/refs/tags/v1.1 create mode 100644 integrations/gitea-repositories-meta/user13/repo11.git/objects/0a/bcb056019adb8336cf9db3ad9d9cf80cd4b141 create mode 100644 integrations/gitea-repositories-meta/user13/repo11.git/objects/75/d1afd00e111c8dbd9e3d96a27b431ac5ae6d74 create mode 100644 integrations/gitea-repositories-meta/user13/repo11.git/objects/ed/447543e0c85d628b91f7f466f4921908f4c5ea create mode 100644 integrations/gitea-repositories-meta/user13/repo11.git/refs/heads/branch2 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/HEAD b/integrations/gitea-repositories-meta/user1/repo1.git/HEAD deleted file mode 100644 index cb089cd89a7d7..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/config b/integrations/gitea-repositories-meta/user1/repo1.git/config deleted file mode 100644 index 07d359d07cf1e..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/config +++ /dev/null @@ -1,4 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/description b/integrations/gitea-repositories-meta/user1/repo1.git/description deleted file mode 100644 index 498b267a8c781..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample deleted file mode 100755 index a5d7b84a67345..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample deleted file mode 100755 index b58d1184a9d43..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive deleted file mode 100755 index 4b3d452abcce2..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/post-receive.d"`; do - sh "$SHELL_FOLDER/post-receive.d/$i" -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea deleted file mode 100755 index 1c70c91d74527..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-receive.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample deleted file mode 100755 index ec17ec1939b7c..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082bcb939..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample deleted file mode 100755 index 68d62d5446d96..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample deleted file mode 100755 index 6187dbf4390fc..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha -do - if [ "$local_sha" = $z40 ] - then - # Handle delete - : - else - if [ "$remote_sha" = $z40 ] - then - # New branch, examine all commits - range="$local_sha" - else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" - fi - - # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] - then - echo >&2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample deleted file mode 100755 index 33730ca647cb2..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -<<\DOC_END - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive deleted file mode 100755 index 412701305369c..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/pre-receive.d"`; do - sh "$SHELL_FOLDER/pre-receive.d/$i" -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea deleted file mode 100755 index 3b2c4c2e04b28..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/pre-receive.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample deleted file mode 100755 index f093a02ec4991..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update deleted file mode 100755 index c186fe4a18b0f..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/update.d"`; do - sh "$SHELL_FOLDER/update.d/$i" $1 $2 $3 -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea deleted file mode 100755 index 14b7b0091a23d..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -#"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample b/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample deleted file mode 100755 index 80ba94135cc37..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to block unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude b/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude deleted file mode 100644 index a5196d1be8fb5..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/info/refs b/integrations/gitea-repositories-meta/user1/repo1.git/info/refs deleted file mode 100644 index ca1df85e2ebfb..0000000000000 --- a/integrations/gitea-repositories-meta/user1/repo1.git/info/refs +++ /dev/null @@ -1 +0,0 @@ -65f1bf27bc3bf70f64657658635e66094edbcb4d refs/heads/master diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b b/integrations/gitea-repositories-meta/user1/repo1.git/objects/15/20e879c0d3943e86ae59a7807693e1f137959b deleted file mode 100644 index 754a83e0cd9cdfb4340dd470b9f6754980631b21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58 zcmV-A0LA}!0ZYosPf{>7Wl&ZqN-fAYR7lG&%1%vDNGrpF diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 b/integrations/gitea-repositories-meta/user1/repo1.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 deleted file mode 100644 index 0994add2c8a420ba89b9a239de84741d4d00ee02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx2y%6F@paY9O=0l%2wWR@KdW}W>d8uz$jVo* MqfO=m05RYX?j~gyApigX diff --git a/integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd b/integrations/gitea-repositories-meta/user1/repo1.git/objects/3d/d8fc8ea15806b347b52a2b7f235536155d6ccd deleted file mode 100644 index 379ee0da3a23da21b44b51259619053dbdef4c58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmb%v7rOCc0q7S-{K(sSa& zkkbhiI`12U*27++lwz~nt#W~Lz0(ZW%yS%}3Kf0bq)P96vj0l1tFo_f7S z=HHwE1gOK)M^jZzS5;)yrn$5^TPTo%)*~@z_q0mI`M|nw$oH1od>(5^t9tni|K$XL z{E(bgN;#4`$M&>G4`{Yd0#e5DYQx4*7$vo9-cKrHP$<+IHuq}eNa-(2bj68D08X~5 zAiJe>0t+ltb{%g4SzTi{8e zl-*;(RZ9+}r>(d@th9G{I`Wo2Hm+b$c){TkxVpxv?Pd(QkJOZ@*=Gd_z{8%gZm*eB z;r>*Q_WDxyT`1yXDacbbv)p{d+vX;&XU)u~&SGD)v$|3!a*bfQWdyLiHs`KkjJ4Y( z(J(UJX%G)+XCkp_YIE>=M`UulJ5n=>;Y6|GV$gLfcx1-)lU5PHe3v2W`MmD=?8ba9 z`&gfQ<0X$jIOM~7@Wl+jj08wZKfVV0p0Lr(;!b

X4thi6>FA(}kLBf~~suR9?^YiTYMOt>8bMmms=l7o^9&z)Q6wh^$SYwIHp3nJ^sA%5<@ ztM?!6cz*J3{b(dNrH08!^+^7W0KW;2A?j9vvFkC>&i^4qG1~VAEV+Nban8En#pOYxNtkR2K z9H~pCE>$*kT{8m`vh*+WR1~1dX_{r|Ljg06$q~h+JXx|OjZjJR6v;!bq%)>SurZm6 zeg=ps$+V={G&`gv3rj>JhD8jA4ora%0`}7PJBXTO0KdP#yIuON z=>M#`q-lT4hVBnQG6<3f5+NGkkb@BW(yzz4_+Q7>SiPDG{QB33ie{XEqdCAcw3FZm z7v*n`0Sq**@eu_})~?7ow`it;Yug>kHY$ zKz&#aXUL2x?>Kug?S6q9w|Y7*j65YOeQ{&?rq~5ECW=~Sax-S@HsM}+_$qLH|9X;+ z7tchn505C3{Vl?P(hE&Ty$$0m<8AD< ztW`p|)f=knMDwMu!VtncA>YSS#>m9;RoAkbKzT9wf{q>;1_<-!!eG3r{P&w7eCIiJ z-Ywl7Z?$DQ;VSj+EkAJ7W4xXXZ%(xEWN-1~YUH<_$ZiD&yeDZr@8dVkHIj}GeTS5| z+C}ckkR0F3$( ANdN!< literal 0 HcmV?d00001 diff --git a/integrations/gitea-repositories-meta/user13/repo11.git/objects/ed/447543e0c85d628b91f7f466f4921908f4c5ea b/integrations/gitea-repositories-meta/user13/repo11.git/objects/ed/447543e0c85d628b91f7f466f4921908f4c5ea new file mode 100644 index 0000000000000000000000000000000000000000..b3a1046feeb8d44c745f3dc828cbfe46e01632c5 GIT binary patch literal 54 zcmb Date: Mon, 10 Jun 2019 10:06:21 +0800 Subject: [PATCH 14/24] fix tests --- integrations/api_repo_test.go | 6 +++--- models/fixtures/repository.yml | 20 +++----------------- models/fixtures/user.yml | 2 +- models/repo_list_test.go | 6 +++--- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 60fe4a3649576..8dedfd1ae0d44 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -70,9 +70,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50&private=false", expectedResults: expectedResults{ - nil: {count: 22}, - user: {count: 22}, - user2: {count: 22}}, + nil: {count: 21}, + user: {count: 21}, + user2: {count: 21}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10&private=false", expectedResults: expectedResults{ nil: {count: 10}, diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 110f9cb722a3a..f43fae3d67e88 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -6,12 +6,11 @@ is_private: false num_issues: 2 num_closed_issues: 1 - num_pulls: 3 + num_pulls: 2 num_closed_pulls: 0 num_milestones: 3 num_closed_milestones: 1 num_watches: 3 - num_forks: 1 - id: 2 @@ -119,7 +118,7 @@ is_private: false num_issues: 0 num_closed_issues: 0 - num_pulls: 0 + num_pulls: 1 num_closed_pulls: 0 is_mirror: false num_forks: 1 @@ -497,17 +496,4 @@ num_stars: 0 num_forks: 0 num_issues: 0 - is_mirror: false - -- - id: 42 - owner_id: 1 - lower_name: forked_repo1 - name: forked_repo1 - is_private: false - num_stars: 0 - num_forks: 0 - num_issues: 0 - is_mirror: false - is_fork: true - fork_id: 1 + is_mirror: false \ No newline at end of file diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index 9f8f81a4ee7a9..ed60e7f5eab06 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -12,7 +12,7 @@ is_admin: true avatar: avatar1 avatar_email: user1@example.com - num_repos: 1 + num_repos: 0 is_active: true - diff --git a/models/repo_list_test.go b/models/repo_list_test.go index b80def5dfcb48..645de2a59a4df 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -147,10 +147,10 @@ func TestSearchRepositoryByName(t *testing.T) { count: 14}, {name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true}, - count: 22}, + count: 21}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, - count: 28}, + count: 27}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName", opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, count: 15}, @@ -159,7 +159,7 @@ func TestSearchRepositoryByName(t *testing.T) { count: 13}, {name: "AllPublic/PublicRepositoriesOfOrganization", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse}, - count: 22}, + count: 21}, } for _, testCase := range testCases { From 1cb0e77d104a94553e68783fa012105488e97039 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 10:44:18 +0800 Subject: [PATCH 15/24] fix tests --- models/fixtures/issue.yml | 2 +- models/fixtures/pull_request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/fixtures/issue.yml b/models/fixtures/issue.yml index c770cdf17d619..585242a14d139 100644 --- a/models/fixtures/issue.yml +++ b/models/fixtures/issue.yml @@ -90,7 +90,7 @@ id: 8 repo_id: 10 index: 1 - poster_id: 1 + poster_id: 11 name: pr2 content: a pull request is_closed: false diff --git a/models/fixtures/pull_request.yml b/models/fixtures/pull_request.yml index 7452b16078b3d..baaaf6bb8a6da 100644 --- a/models/fixtures/pull_request.yml +++ b/models/fixtures/pull_request.yml @@ -32,7 +32,7 @@ type: 0 # gitea pull request status: 2 # mergable issue_id: 8 - index: 4 + index: 1 head_repo_id: 11 base_repo_id: 10 head_user_name: user13 From 3ed52ebd62861a855e82893a8006c478c8f7a604 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 12:50:15 +0800 Subject: [PATCH 16/24] fix migration --- models/migrations/migrations.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index e8fb42c492ea7..7a5b0c4184309 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -229,6 +229,8 @@ var migrations = []Migration{ NewMigration("add http method to webhook", addHTTPMethodToWebhook), // v87 -> v88 NewMigration("add avatar field to repository", addAvatarFieldToRepository), + // v88 -> v89 + NewMigration("add commit status context field to commit_status", addCommitStatusContext), } // Migrate database to current version From 9edee63a2c74016325828472a330e5a1d2af3472 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 17:37:37 +0800 Subject: [PATCH 17/24] keep db size consistency --- models/commit_status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/commit_status.go b/models/commit_status.go index 144f6950e8aec..9d145b1f9fece 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -59,7 +59,7 @@ type CommitStatus struct { SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"` TargetURL string `xorm:"TEXT"` Description string `xorm:"TEXT"` - ContextHash string `xorm:"varchar(64) index"` + ContextHash string `xorm:"varchar(40) index"` Context string `xorm:"TEXT"` Creator *User `xorm:"-"` CreatorID int64 From 41362de04cf430142d12ca8f2ee8551f6a5e408f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 17:41:15 +0800 Subject: [PATCH 18/24] fix translation --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 815903d94c62f..223df91fda469 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -983,7 +983,7 @@ pulls.invalid_merge_option = You cannot use this merge option for this pull requ pulls.open_unmerged_pull_exists = `You cannot perform a reopen operation because there is a pending pull request (#%d) with identical properties.` pulls.status_checking = Some checks are pending pulls.status_checks_success = All checks were successful -pulls.status_checks_error = Some checks were not successful +pulls.status_checks_error = Some checks failed milestones.new = New Milestone milestones.open_tab = %d Open From a606860734b1e35be2ee8693428f9c3f39125c9c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 23:51:34 +0800 Subject: [PATCH 19/24] change commit hash status table unique index --- models/commit_status.go | 29 +++++------------------------ models/migrations/v88.go | 4 ++-- modules/repofiles/commit_status.go | 2 +- routers/api/v1/repo/status.go | 12 +++--------- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/models/commit_status.go b/models/commit_status.go index 9d145b1f9fece..6c9dd5761deca 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -156,27 +156,6 @@ func GetLatestCommitStatus(repo *Repository, sha string, page int) ([]*CommitSta return statuses, x.In("id", ids).Find(&statuses) } -// GetCommitStatus populates a given status for a given commit. -// NOTE: If ID or Index isn't given, and only Context, TargetURL and/or Description -// is given, the CommitStatus created _last_ will be returned. -func GetCommitStatus(repo *Repository, sha string, status *CommitStatus) (*CommitStatus, error) { - conds := &CommitStatus{ - Context: status.Context, - State: status.State, - TargetURL: status.TargetURL, - Description: status.Description, - } - has, err := x.Where("repo_id = ?", repo.ID).And("sha = ?", sha).Desc("created_unix").Get(conds) - if err != nil { - return nil, fmt.Errorf("GetCommitStatus[%s, %s]: %v", repo.RepoPath(), sha, err) - } - if !has { - return nil, fmt.Errorf("GetCommitStatus[%s, %s]: not found", repo.RepoPath(), sha) - } - - return conds, nil -} - // NewCommitStatusOptions holds options for creating a CommitStatus type NewCommitStatusOptions struct { Repo *Repository @@ -240,7 +219,9 @@ func NewCommitStatus(opts NewCommitStatusOptions) error { return fmt.Errorf("Insert CommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) } - exist, err := sess.Table("commit_status_context").Where("context_hash = ?", opts.CommitStatus.ContextHash).Exist() + exist, err := sess.Table("commit_status_context"). + Where("repo_id =? AND context_hash = ?", opts.Repo.ID, opts.CommitStatus.ContextHash). + Exist() if err != nil { return fmt.Errorf("Check CommistStatusContext Exist failed: %v", err) } @@ -297,8 +278,8 @@ func HashCommitStatusContext(context string) string { // CommitStatusContext represents commit status context type CommitStatusContext struct { ID int64 - RepoID int64 `xorm:"index"` - ContextHash string `xorm:"varchar(40) unique"` + RepoID int64 `xorm:"index unique(s)"` + ContextHash string `xorm:"varchar(40) unique(s)"` ContextLogo string `xorm:"TEXT"` Context string `xorm:"TEXT"` CreatedUnix util.TimeStamp `xorm:"created"` diff --git a/models/migrations/v88.go b/models/migrations/v88.go index a1ec31e15a704..f50c2d6ee8616 100644 --- a/models/migrations/v88.go +++ b/models/migrations/v88.go @@ -66,8 +66,8 @@ func addCommitStatusContext(x *xorm.Engine) error { type CommitStatusContext struct { ID int64 - RepoID int64 `xorm:"index"` - ContextHash string `xorm:"varchar(64) unique"` + RepoID int64 `xorm:"index unique(s)"` + ContextHash string `xorm:"varchar(40) unique(s)"` ContextLogo string `xorm:"TEXT"` Context string `xorm:"TEXT"` CreatedUnix util.TimeStamp `xorm:"created"` diff --git a/modules/repofiles/commit_status.go b/modules/repofiles/commit_status.go index 2148ff463d6f2..f3dfbf209f7dd 100644 --- a/modules/repofiles/commit_status.go +++ b/modules/repofiles/commit_status.go @@ -14,7 +14,7 @@ import ( // CreateCommitStatus creates a new CommitStatus given a bunch of parameters // NOTE: All text-values will be trimmed from whitespaces. // Requires: Repo, Creator, SHA -func CreateCommitStatus(repo *models.Repository, creator *models.User, sha string, status *models.CommitStatus, isOAuth bool) error { +func CreateCommitStatus(repo *models.Repository, creator *models.User, sha string, status *models.CommitStatus) error { repoPath := repo.RepoPath() // confirm that commit is exist diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 0117536b184a2..1aa4f4e1a1c0c 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -58,18 +58,12 @@ func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) { Description: form.Description, Context: form.Context, } - isOAuthToken := ctx.Data["IsApiToken"] == true - if err := repofiles.CreateCommitStatus(ctx.Repo.Repository, ctx.User, sha, status, isOAuthToken); err != nil { - ctx.Error(500, "NewCommitStatus", err) + if err := repofiles.CreateCommitStatus(ctx.Repo.Repository, ctx.User, sha, status); err != nil { + ctx.Error(500, "CreateCommitStatus", err) return } - newStatus, err := models.GetCommitStatus(ctx.Repo.Repository, sha, status) - if err != nil { - ctx.Error(500, "GetCommitStatus", err) - return - } - ctx.JSON(201, newStatus.APIFormat()) + ctx.JSON(201, status.APIFormat()) } // GetCommitStatuses returns all statuses for any given commit hash From f05b354232399e88682f951066e33988263dae4f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 11 Jun 2019 23:42:03 +0800 Subject: [PATCH 20/24] remove unused table --- models/commit_status.go | 41 ---------------------------------------- models/migrations/v88.go | 13 +------------ 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/models/commit_status.go b/models/commit_status.go index 6c9dd5761deca..7cb2e6a4d9e7a 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -219,23 +219,6 @@ func NewCommitStatus(opts NewCommitStatusOptions) error { return fmt.Errorf("Insert CommitStatus[%s, %s]: %v", repoPath, opts.SHA, err) } - exist, err := sess.Table("commit_status_context"). - Where("repo_id =? AND context_hash = ?", opts.Repo.ID, opts.CommitStatus.ContextHash). - Exist() - if err != nil { - return fmt.Errorf("Check CommistStatusContext Exist failed: %v", err) - } - if !exist { - if _, err = sess.Insert(&CommitStatusContext{ - RepoID: opts.Repo.ID, - ContextHash: opts.CommitStatus.ContextHash, - ContextLogo: "", - Context: opts.CommitStatus.Context, - }); err != nil { - return fmt.Errorf("Insert CommitStatusContext[%s, %s]: %v", repoPath, opts.SHA, err) - } - } - return sess.Commit() } @@ -274,27 +257,3 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List func HashCommitStatusContext(context string) string { return fmt.Sprintf("%x", md5.Sum([]byte(context))) } - -// CommitStatusContext represents commit status context -type CommitStatusContext struct { - ID int64 - RepoID int64 `xorm:"index unique(s)"` - ContextHash string `xorm:"varchar(40) unique(s)"` - ContextLogo string `xorm:"TEXT"` - Context string `xorm:"TEXT"` - CreatedUnix util.TimeStamp `xorm:"created"` -} - -// FindRepoCommitStatusContexts find repository's commit status contexts -func FindRepoCommitStatusContexts(repoID int64) ([]string, error) { - var contexts = make([]string, 0, 3) - err := x.Where("repo_id = ?", repoID).Table("commit_status_context").Find(&contexts) - if err != nil { - return nil, err - } - return contexts, nil -} - -func init() { - tables = append(tables, new(CommitStatusContext)) -} diff --git a/models/migrations/v88.go b/models/migrations/v88.go index f50c2d6ee8616..0c7825a5d3d94 100644 --- a/models/migrations/v88.go +++ b/models/migrations/v88.go @@ -8,8 +8,6 @@ import ( "crypto/md5" "fmt" - "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/xorm" ) @@ -64,14 +62,5 @@ func addCommitStatusContext(x *xorm.Engine) error { start += len(statuses) } - type CommitStatusContext struct { - ID int64 - RepoID int64 `xorm:"index unique(s)"` - ContextHash string `xorm:"varchar(40) unique(s)"` - ContextLogo string `xorm:"TEXT"` - Context string `xorm:"TEXT"` - CreatedUnix util.TimeStamp `xorm:"created"` - } - - return x.Sync2(new(CommitStatusContext)) + return nil } From 6c633cc04f0d1babe8265fed0842435dc2fefa28 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 24 Jun 2019 11:20:53 +0800 Subject: [PATCH 21/24] use char instead varchar --- models/commit_status.go | 6 +++--- models/migrations/v88.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/models/commit_status.go b/models/commit_status.go index 7cb2e6a4d9e7a..3f743c0c0988b 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -6,7 +6,7 @@ package models import ( "container/list" - "crypto/md5" + "crypto/sha1" "fmt" "strings" @@ -59,7 +59,7 @@ type CommitStatus struct { SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"` TargetURL string `xorm:"TEXT"` Description string `xorm:"TEXT"` - ContextHash string `xorm:"varchar(40) index"` + ContextHash string `xorm:"char(40) index"` Context string `xorm:"TEXT"` Creator *User `xorm:"-"` CreatorID int64 @@ -255,5 +255,5 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List // HashCommitStatusContext hash context func HashCommitStatusContext(context string) string { - return fmt.Sprintf("%x", md5.Sum([]byte(context))) + return fmt.Sprintf("%x", sha1.Sum([]byte(context))) } diff --git a/models/migrations/v88.go b/models/migrations/v88.go index 0c7825a5d3d94..fef425db0ac91 100644 --- a/models/migrations/v88.go +++ b/models/migrations/v88.go @@ -5,20 +5,20 @@ package migrations import ( - "crypto/md5" + "crypto/sha1" "fmt" "github.com/go-xorm/xorm" ) func hashContext(context string) string { - return fmt.Sprintf("%x", md5.Sum([]byte(context))) + return fmt.Sprintf("%x", sha1.Sum([]byte(context))) } func addCommitStatusContext(x *xorm.Engine) error { type CommitStatus struct { ID int64 `xorm:"pk autoincr"` - ContextHash string `xorm:"varchar(40) index"` + ContextHash string `xorm:"char(40) index"` Context string `xorm:"TEXT"` } From ea4a0870c646c809fe5cd517e3c94ab6c273a1d6 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 26 Jun 2019 23:12:25 +0800 Subject: [PATCH 22/24] make hashCommitStatusContext private --- models/commit_status.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/commit_status.go b/models/commit_status.go index 3f743c0c0988b..74a27563030a6 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -209,7 +209,7 @@ func NewCommitStatus(opts NewCommitStatusOptions) error { opts.CommitStatus.Index = nextIndex + 1 log.Debug("NewCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index) - opts.CommitStatus.ContextHash = HashCommitStatusContext(opts.CommitStatus.Context) + opts.CommitStatus.ContextHash = hashCommitStatusContext(opts.CommitStatus.Context) // Insert new CommitStatus if _, err = sess.Insert(opts.CommitStatus); err != nil { @@ -253,7 +253,7 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List return newCommits } -// HashCommitStatusContext hash context -func HashCommitStatusContext(context string) string { +// hashCommitStatusContext hash context +func hashCommitStatusContext(context string) string { return fmt.Sprintf("%x", sha1.Sum([]byte(context))) } From 4ab23d4f2285e120eda47a01541b55bbf94d604f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 30 Jun 2019 12:34:18 +0800 Subject: [PATCH 23/24] split merge section with status check on pull view ui --- public/css/index.css | 1 + public/less/_repository.less | 5 +++++ templates/repo/issue/view_content/pull.tmpl | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/css/index.css b/public/css/index.css index 2bf2f961814c9..3418847a4fbd3 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -535,6 +535,7 @@ footer .ui.left,footer .ui.right{line-height:40px} .repository.view.issue .comment-list .comment .content>.header:before{border-right-color:#d3d3d4;border-width:9px;margin-top:-9px} .repository.view.issue .comment-list .comment .content>.header:after{border-right-color:#f7f7f7;border-width:8px;margin-top:-8px} .repository.view.issue .comment-list .comment .content>.header .text{max-width:78%;padding-top:10px;padding-bottom:10px} +.repository.view.issue .comment-list .comment .content>.merge-section{border-top:1px solid #d4d4d5;background-color:#f7f7f7} .repository.view.issue .comment-list .comment .content .markdown{font-size:14px} .repository.view.issue .comment-list .comment .content .no-content{color:#767676;font-style:italic} .repository.view.issue .comment-list .comment .content>.bottom.segment{background:#f3f4f5} diff --git a/public/less/_repository.less b/public/less/_repository.less index a8b2e22569486..5a57f5db71975 100644 --- a/public/less/_repository.less +++ b/public/less/_repository.less @@ -813,6 +813,11 @@ } } + > .merge-section { + border-top: 1px solid #d4d4d5; + background-color: #f7f7f7; + } + .markdown { font-size: 14px; } diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index e3135de1308af..caadba41c70fd 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -46,7 +46,7 @@ {{else}}red{{end}}">

{{template "repo/pulls/status" .}} -
+
{{if .Issue.PullRequest.HasMerged}}
{{$.i18n.Tr "repo.pulls.has_merged"}} From 18bb02ea3c747eae886a305c09a65c8a93505c97 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 30 Jun 2019 13:05:29 +0800 Subject: [PATCH 24/24] fix tests; fix arc-green theme on pull ui --- integrations/pull_merge_test.go | 2 +- public/css/theme-arc-green.css | 1 + public/less/themes/arc-green.less | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go index 1f0ad27a0b5b9..4266a194ebfd3 100644 --- a/integrations/pull_merge_test.go +++ b/integrations/pull_merge_test.go @@ -159,7 +159,7 @@ func TestCantMergeWorkInProgress(t *testing.T) { req := NewRequest(t, "GET", resp.Header().Get("Location")) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - text := strings.TrimSpace(htmlDoc.doc.Find(".merge.segment > .text.grey").Text()) + text := strings.TrimSpace(htmlDoc.doc.Find(".merge-section.segment > .text.grey").Text()) assert.NotEmpty(t, text, "Can't find WIP text") // remove from lang diff --git a/public/css/theme-arc-green.css b/public/css/theme-arc-green.css index e94b150cdc28e..a93404cad097f 100644 --- a/public/css/theme-arc-green.css +++ b/public/css/theme-arc-green.css @@ -111,6 +111,7 @@ footer{background:#2e323e;border-top:1px solid #313131} .ui.attached.segment{border:1px solid #404552} .repository.view.issue .comment-list .comment .content>.bottom.segment{background:#353945} .repository.view.issue .comment-list .comment .content .header{color:#dbdbdb;background-color:#404552;border-bottom:1px solid #353944} +.repository.view.issue .comment-list .comment .content .merge-section{background-color:#404552;border-top:1px solid #353944} .ui .text.grey a{color:#dbdbdb!important} .ui.comments .comment .actions a{color:#dbdbdb} .repository.view.issue .comment-list .comment .content .header:after{border-right-color:#404552} diff --git a/public/less/themes/arc-green.less b/public/less/themes/arc-green.less index 4fd98280effcb..4780756bce22c 100644 --- a/public/less/themes/arc-green.less +++ b/public/less/themes/arc-green.less @@ -590,6 +590,11 @@ a.ui.basic.green.label:hover { border-bottom: 1px solid #353944; } +.repository.view.issue .comment-list .comment .content .merge-section { + background-color: #404552; + border-top: 1px solid #353944; +} + .ui .text.grey a { color: #dbdbdb !important; }