summaryrefslogtreecommitdiffstats
path: root/models/git
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2022-12-28 18:03:21 +0800
committerGitHub <noreply@github.com>2022-12-28 11:03:21 +0100
commite9bc2c77c35d078c5ba5e6107c3551f31410c936 (patch)
tree8c0b771a9efe60101fd5520db7403ed9c59e2f31 /models/git
parent9b4da56963692819d236b07504e565d4b4fb4021 (diff)
downloadgitea-e9bc2c77c35d078c5ba5e6107c3551f31410c936.tar.gz
gitea-e9bc2c77c35d078c5ba5e6107c3551f31410c936.zip
Use complete SHA to create and query commit status (#22244) (#22257)
Backport #22244. Fix #13485. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/git')
-rw-r--r--models/git/commit_status.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/models/git/commit_status.go b/models/git/commit_status.go
index 53c5458040..9e7fb5f805 100644
--- a/models/git/commit_status.go
+++ b/models/git/commit_status.go
@@ -281,6 +281,10 @@ func NewCommitStatus(opts NewCommitStatusOptions) error {
return fmt.Errorf("NewCommitStatus[%s, %s]: no user specified", repoPath, opts.SHA)
}
+ if _, err := git.NewIDFromString(opts.SHA); err != nil {
+ return fmt.Errorf("NewCommitStatus[%s, %s]: invalid sha: %w", repoPath, opts.SHA, err)
+ }
+
ctx, committer, err := db.TxContext()
if err != nil {
return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %w", opts.Repo.ID, opts.Creator.ID, opts.SHA, err)