mirror of https://github.com/go-gitea/gitea.git
Revert headcommitid change
parent
cbce199b98
commit
98175f1a93
|
|
@ -138,6 +138,7 @@ type PullRequest struct {
|
|||
BaseRepoID int64 `xorm:"INDEX"`
|
||||
BaseRepo *repo_model.Repository `xorm:"-"`
|
||||
HeadBranch string
|
||||
HeadCommitID string `xorm:"-"`
|
||||
BaseBranch string
|
||||
MergeBase string `xorm:"VARCHAR(64)"`
|
||||
AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ func NewComment(ctx *context.Context) {
|
|||
|
||||
// Regenerate patch and test conflict.
|
||||
if pr == nil {
|
||||
issue.PullRequest.HeadCommitID = ""
|
||||
pull_service.StartPullRequestCheckImmediately(ctx, issue.PullRequest)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -318,12 +318,7 @@ func UpdateViewedFiles(ctx *context.Context) {
|
|||
|
||||
// Expect the review to have been now if no head commit was supplied
|
||||
if data.HeadCommitSHA == "" {
|
||||
data.HeadCommitSHA, err = ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitHeadRefName())
|
||||
if err != nil {
|
||||
log.Warn("Attempted to get ref commit id: %v", err)
|
||||
ctx.Resp.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
data.HeadCommitSHA = pull.HeadCommitID
|
||||
}
|
||||
|
||||
updatedFiles := make(map[string]pull_model.ViewedState, len(data.Files))
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ func TestRenderConversation(t *testing.T) {
|
|||
|
||||
var preparedComment *issues_model.Comment
|
||||
run("prepare", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
assert.NoError(t, err)
|
||||
comment, err := pull.CreateCodeComment(ctx, pr.Issue.Poster, ctx.Repo.GitRepo, pr.Issue, 1, "content", "", false, 0, headCommitID, nil)
|
||||
comment, err := pull.CreateCodeComment(ctx, pr.Issue.Poster, ctx.Repo.GitRepo, pr.Issue, 1, "content", "", false, 0, pr.HeadCommitID, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
comment.Invalidated = true
|
||||
|
|
|
|||
|
|
@ -142,21 +142,21 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
|
|||
}
|
||||
|
||||
pr := &issues_model.PullRequest{
|
||||
HeadRepoID: repo.ID,
|
||||
BaseRepoID: repo.ID,
|
||||
HeadBranch: headBranch,
|
||||
BaseBranch: baseBranchName,
|
||||
HeadRepo: repo,
|
||||
BaseRepo: repo,
|
||||
MergeBase: "",
|
||||
Type: issues_model.PullRequestGitea,
|
||||
Flow: issues_model.PullRequestFlowAGit,
|
||||
HeadRepoID: repo.ID,
|
||||
BaseRepoID: repo.ID,
|
||||
HeadBranch: headBranch,
|
||||
HeadCommitID: opts.NewCommitIDs[i],
|
||||
BaseBranch: baseBranchName,
|
||||
HeadRepo: repo,
|
||||
BaseRepo: repo,
|
||||
MergeBase: "",
|
||||
Type: issues_model.PullRequestGitea,
|
||||
Flow: issues_model.PullRequestFlowAGit,
|
||||
}
|
||||
prOpts := &pull_service.NewPullRequestOptions{
|
||||
Repo: repo,
|
||||
Issue: prIssue,
|
||||
PullRequest: pr,
|
||||
HeadCommitID: opts.NewCommitIDs[i],
|
||||
Repo: repo,
|
||||
Issue: prIssue,
|
||||
PullRequest: pr,
|
||||
}
|
||||
if err := pull_service.NewPullRequest(ctx, prOpts); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -214,7 +214,8 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
|
|||
}
|
||||
}
|
||||
|
||||
if err = pull_service.UpdatePullRequestAgitFlowHead(ctx, pr, opts.NewCommitIDs[i]); err != nil {
|
||||
pr.HeadCommitID = opts.NewCommitIDs[i]
|
||||
if err = pull_service.UpdatePullRequestAgitFlowHead(ctx, pr, pr.HeadCommitID); err != nil {
|
||||
return nil, fmt.Errorf("failed to update pull ref. Error: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,12 +100,11 @@ func testPullRequestTmpRepoBranchMergeable(ctx context.Context, prCtx *prTmpRepo
|
|||
}
|
||||
}
|
||||
pr.MergeBase = strings.TrimSpace(pr.MergeBase)
|
||||
headCommitID, err := gitRepo.GetRefCommitID(git.BranchPrefix + "tracking")
|
||||
if err != nil {
|
||||
if pr.HeadCommitID, err = gitRepo.GetRefCommitID(git.BranchPrefix + "tracking"); err != nil {
|
||||
return fmt.Errorf("GetBranchCommitID: can't find commit ID for head: %w", err)
|
||||
}
|
||||
|
||||
if headCommitID == pr.MergeBase {
|
||||
if pr.HeadCommitID == pr.MergeBase {
|
||||
pr.Status = issues_model.PullRequestStatusAncestor
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ func getPullWorkingLockKey(prID int64) string {
|
|||
type NewPullRequestOptions struct {
|
||||
Repo *repo_model.Repository
|
||||
Issue *issues_model.Issue
|
||||
HeadCommitID string
|
||||
LabelIDs []int64
|
||||
AttachmentUUIDs []string
|
||||
PullRequest *issues_model.PullRequest
|
||||
|
|
@ -54,7 +53,7 @@ type NewPullRequestOptions struct {
|
|||
|
||||
// NewPullRequest creates new pull request with labels for repository.
|
||||
func NewPullRequest(ctx context.Context, opts *NewPullRequestOptions) error {
|
||||
if opts.PullRequest.Flow == issues_model.PullRequestFlowAGit && opts.HeadCommitID == "" {
|
||||
if opts.PullRequest.Flow == issues_model.PullRequestFlowAGit && opts.PullRequest.HeadCommitID == "" {
|
||||
return errors.New("head commit ID cannot be empty for agit flow")
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ func NewPullRequest(ctx context.Context, opts *NewPullRequestOptions) error {
|
|||
|
||||
// update head commit id into git repository
|
||||
if pr.Flow == issues_model.PullRequestFlowAGit {
|
||||
err = UpdatePullRequestAgitFlowHead(ctx, pr, opts.HeadCommitID)
|
||||
err = UpdatePullRequestAgitFlowHead(ctx, pr, pr.HeadCommitID)
|
||||
} else {
|
||||
err = UpdatePullRequestGithubFlowHead(ctx, pr)
|
||||
}
|
||||
|
|
@ -771,12 +770,12 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
|
|||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
headCommit, err = gitRepo.GetBranchCommit(pr.HeadBranch)
|
||||
} else {
|
||||
headCommitID, err1 := gitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
if err1 != nil {
|
||||
log.Error("Unable to get head commit: %s Error: %v", pr.GetGitHeadRefName(), err1)
|
||||
pr.HeadCommitID, err = gitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
if err != nil {
|
||||
log.Error("Unable to get head commit: %s Error: %v", pr.GetGitHeadRefName(), err)
|
||||
return ""
|
||||
}
|
||||
headCommit, err = gitRepo.GetCommit(headCommitID)
|
||||
headCommit, err = gitRepo.GetCommit(pr.HeadCommitID)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error("Unable to get head commit: %s Error: %v", pr.HeadBranch, err)
|
||||
|
|
@ -998,11 +997,11 @@ func IsHeadEqualWithBranch(ctx context.Context, pr *issues_model.PullRequest, br
|
|||
return false, err
|
||||
}
|
||||
} else {
|
||||
headCommitID, err := baseGitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
pr.HeadCommitID, err = baseGitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if headCommit, err = baseGitRepo.GetCommit(headCommitID); err != nil {
|
||||
if headCommit, err = baseGitRepo.GetCommit(pr.HeadCommitID); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,10 +166,13 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
|
|||
}
|
||||
|
||||
trackingBranch := "tracking"
|
||||
objectFormat := git.ObjectFormatFromName(pr.BaseRepo.ObjectFormatName)
|
||||
// Fetch head branch
|
||||
var headBranch string
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
headBranch = git.BranchPrefix + pr.HeadBranch
|
||||
} else if len(pr.HeadCommitID) == objectFormat.FullLength() { // for not created pull request
|
||||
headBranch = pr.HeadCommitID
|
||||
} else {
|
||||
headBranch = pr.GetGitHeadRefName()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ func TestAgitReviewStaleness(t *testing.T) {
|
|||
assert.NoError(t, pr.LoadIssue(t.Context()))
|
||||
|
||||
// Get initial commit ID for the review
|
||||
initialCommitID, err := gitRepo.GetRefCommitID(pr.GetGitHeadRefName())
|
||||
initialCommitID := pr.HeadCommitID
|
||||
assert.NoError(t, err)
|
||||
t.Logf("Initial commit ID: %s", initialCommitID)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue