diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-07-10 19:18:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 11:18:55 +0000 |
commit | 2f31d2d56c22400b2e79b279a5d0e845febba137 (patch) | |
tree | b6e5d1aecacba0d9a4f8e2aeec9dcbb81f0bd623 | |
parent | 0fd1672ae49a5f69fca7d90336ae75be83a21014 (diff) | |
download | gitea-2f31d2d56c22400b2e79b279a5d0e845febba137.tar.gz gitea-2f31d2d56c22400b2e79b279a5d0e845febba137.zip |
Exclude default branch from pushed branch hint (#25795)
When pushing to default branch, no pushing hint should be prompt.
Fix #25778
---------
Co-authored-by: Giteabot <teabot@gitea.io>
-rw-r--r-- | models/git/branch.go | 4 | ||||
-rw-r--r-- | routers/web/repo/view.go | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/models/git/branch.go b/models/git/branch.go index 97891f01eb..d57b72719c 100644 --- a/models/git/branch.go +++ b/models/git/branch.go @@ -382,7 +382,8 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str } // FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 6 hours which has no opened PRs created -func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64) (BranchList, error) { +// except the indicate branch +func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64, excludeBranchName string) (BranchList, error) { branches := make(BranchList, 0, 2) subQuery := builder.Select("head_branch").From("pull_request"). InnerJoin("issue", "issue.id = pull_request.issue_id"). @@ -392,6 +393,7 @@ func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64) (B }) err := db.GetEngine(ctx). Where("pusher_id=? AND is_deleted=?", userID, false). + And("name <> ?", excludeBranchName). And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()). NotIn("name", subQuery). OrderBy("branch.updated_unix DESC"). diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index acea08d629..ece2ec5416 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -982,7 +982,7 @@ func renderCode(ctx *context.Context) { ctx.ServerError("GetBaseRepo", err) return } - ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID) + ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch) if err != nil { ctx.ServerError("GetRecentlyPushedBranches", err) return |