summaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/check.go12
-rw-r--r--services/pull/merge.go2
-rw-r--r--services/pull/temp_repo.go2
3 files changed, 8 insertions, 8 deletions
diff --git a/services/pull/check.go b/services/pull/check.go
index ed4b18107c..86460cd49c 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -199,19 +199,19 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com
return nil, fmt.Errorf("ReadFile(%s): %w", headFile, err)
}
commitID := string(commitIDBytes)
- if len(commitID) < 40 {
+ if len(commitID) < git.SHAFullLength {
return nil, fmt.Errorf(`ReadFile(%s): invalid commit-ID "%s"`, headFile, commitID)
}
- cmd := commitID[:40] + ".." + pr.BaseBranch
+ cmd := commitID[:git.SHAFullLength] + ".." + pr.BaseBranch
// Get the commit from BaseBranch where the pull request got merged
mergeCommit, _, err := git.NewCommand(ctx, "rev-list", "--ancestry-path", "--merges", "--reverse").AddDynamicArguments(cmd).
RunStdString(&git.RunOpts{Dir: "", Env: []string{"GIT_INDEX_FILE=" + indexTmpPath, "GIT_DIR=" + pr.BaseRepo.RepoPath()}})
if err != nil {
return nil, fmt.Errorf("git rev-list --ancestry-path --merges --reverse: %w", err)
- } else if len(mergeCommit) < 40 {
+ } else if len(mergeCommit) < git.SHAFullLength {
// PR was maybe fast-forwarded, so just use last commit of PR
- mergeCommit = commitID[:40]
+ mergeCommit = commitID[:git.SHAFullLength]
}
gitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath())
@@ -220,9 +220,9 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com
}
defer gitRepo.Close()
- commit, err := gitRepo.GetCommit(mergeCommit[:40])
+ commit, err := gitRepo.GetCommit(mergeCommit[:git.SHAFullLength])
if err != nil {
- return nil, fmt.Errorf("GetMergeCommit[%v]: %w", mergeCommit[:40], err)
+ return nil, fmt.Errorf("GetMergeCommit[%v]: %w", mergeCommit[:git.SHAFullLength], err)
}
return commit, nil
diff --git a/services/pull/merge.go b/services/pull/merge.go
index 1c42c1c17b..41ba45c177 100644
--- a/services/pull/merge.go
+++ b/services/pull/merge.go
@@ -839,7 +839,7 @@ func MergedManually(pr *issues_model.PullRequest, doer *user_model.User, baseGit
return models.ErrInvalidMergeStyle{ID: pr.BaseRepo.ID, Style: repo_model.MergeStyleManuallyMerged}
}
- if len(commitID) < 40 {
+ if len(commitID) < git.SHAFullLength {
return fmt.Errorf("Wrong commit ID")
}
diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go
index 842719467f..d49a15cea0 100644
--- a/services/pull/temp_repo.go
+++ b/services/pull/temp_repo.go
@@ -166,7 +166,7 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
var headBranch string
if pr.Flow == issues_model.PullRequestFlowGithub {
headBranch = git.BranchPrefix + pr.HeadBranch
- } else if len(pr.HeadCommitID) == 40 { // for not created pull request
+ } else if len(pr.HeadCommitID) == git.SHAFullLength { // for not created pull request
headBranch = pr.HeadCommitID
} else {
headBranch = pr.GetGitRefName()