diff options
author | Markus Koller <mkoller@gitlab.com> | 2019-06-13 12:44:41 +0200 |
---|---|---|
committer | Markus Koller <mkoller@gitlab.com> | 2019-07-18 09:19:18 +0200 |
commit | f8cecafb07792bcaf9d7ffa85766c3b33c1dd252 (patch) | |
tree | abafa6e9dbbb602f61b83abff508acbae074ceee /lib/gitlab/git.rb | |
parent | b921b2d1fb0c1cb3e6d4f3c88806855b48827855 (diff) | |
download | gitlab-ce-f8cecafb07792bcaf9d7ffa85766c3b33c1dd252.tar.gz |
Add start_sha to commits API
When passing start_branch on committing from the WebIDE, it's possible
that the branch has changed since editing started, which results in the
change being applied on top of the latest commit in the branch and
overwriting the new changes.
By passing the start_sha instead we can make sure that the change is
applied on top of the commit which the user started editing from.
Diffstat (limited to 'lib/gitlab/git.rb')
-rw-r--r-- | lib/gitlab/git.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb index 44a62586a23..df9f33baec2 100644 --- a/lib/gitlab/git.rb +++ b/lib/gitlab/git.rb @@ -9,6 +9,7 @@ module Gitlab # https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012 EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze BLANK_SHA = ('0' * 40).freeze + COMMIT_ID = /\A[0-9a-f]{40}\z/.freeze TAG_REF_PREFIX = "refs/tags/".freeze BRANCH_REF_PREFIX = "refs/heads/".freeze @@ -65,6 +66,10 @@ module Gitlab ref == BLANK_SHA end + def commit_id?(ref) + COMMIT_ID.match?(ref) + end + def version Gitlab::Git::Version.git_version end |