aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-03-27 10:34:10 +0800
committerGitHub <noreply@github.com>2024-03-27 02:34:10 +0000
commit538790ad1db8bf66942ff2ead4ef78df5ab8b702 (patch)
tree20f455eda554c8e14e557ee31d13f58edd7b3213 /services/pull
parentf47e00d9d3c3bd58b5944a29c4ff5cec0357520a (diff)
downloadgitea-538790ad1db8bf66942ff2ead4ef78df5ab8b702.tar.gz
gitea-538790ad1db8bf66942ff2ead4ef78df5ab8b702.zip
Put an edit file button on pull request files to allow a quick operation (#29697)
Resolve #23848 This PR put an edit file button on pull request files to allow a quick edit for a file. After the edit finished, it will return back to the viewed file position on pull request files tab. It also use a branch view file link instead of commit link when it's a non-commit pull request files view. <img width="1532" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/3637ca4c-89d5-4621-847b-79702a44f617"> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/pull.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 4289e2e6e1..c091b8608a 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -526,6 +526,25 @@ func pushToBaseRepoHelper(ctx context.Context, pr *issues_model.PullRequest, pre
return nil
}
+// UpdatePullsRefs update all the PRs head file pointers like /refs/pull/1/head so that it will be dependent by other operations
+func UpdatePullsRefs(ctx context.Context, repo *repo_model.Repository, update *repo_module.PushUpdateOptions) {
+ branch := update.RefFullName.BranchName()
+ // GetUnmergedPullRequestsByHeadInfo() only return open and unmerged PR.
+ prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(ctx, repo.ID, branch)
+ if err != nil {
+ log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repo.ID, branch, err)
+ } else {
+ for _, pr := range prs {
+ log.Trace("Updating PR[%d]: composing new test task", pr.ID)
+ if pr.Flow == issues_model.PullRequestFlowGithub {
+ if err := PushToBaseRepo(ctx, pr); err != nil {
+ log.Error("PushToBaseRepo: %v", err)
+ }
+ }
+ }
+ }
+}
+
// UpdateRef update refs/pull/id/head directly for agit flow pull request
func UpdateRef(ctx context.Context, pr *issues_model.PullRequest) (err error) {
log.Trace("UpdateRef[%d]: upgate pull request ref in base repo '%s'", pr.ID, pr.GetGitRefName())