Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: Don't reset last active branch to wrong commit #5919

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed the ``Git`` source step causing last active branch to point to wrong commits.
This only affected the branch state in the repository, the checked out code was correct.
7 changes: 3 additions & 4 deletions master/buildbot/steps/source/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _fetch(self, _):
rev = self.revision
else:
rev = 'FETCH_HEAD'
command = ['reset', '--hard', rev, '--']
command = ['checkout', '-f', rev]
abandonOnFailure = not self.retryFetch and not self.clobberOnFailure
res = yield self._dovccmd(command, abandonOnFailure)

Expand Down Expand Up @@ -424,9 +424,8 @@ def _fullClone(self, shallowClone=False):

# If revision specified checkout that revision
if self.revision:
res = yield self._dovccmd(['reset', '--hard',
self.revision, '--'],
shallowClone)
res = yield self._dovccmd(['checkout', '-f', self.revision], shallowClone)

# init and update submodules, recursively. If there's not recursion
# it will not do it.
if self.submodules:
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/test/unit/steps/test_source_gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_mode_full_clean(self):
'gerrit_branch', '--progress'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
command=['git', 'checkout', '-f', 'FETCH_HEAD'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'checkout', '-B', 'gerrit_branch'])
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_mode_full_clean_force_build(self):
'refs/changes/34/1234/567', '--progress'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
command=['git', 'checkout', '-f', 'FETCH_HEAD'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'checkout', '-B', 'refs/changes/34/1234/567'])
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_mode_full_clean_force_same_project(self):
'refs/changes/34/1234/567', '--progress'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
command=['git', 'checkout', '-f', 'FETCH_HEAD'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'checkout', '-B', 'refs/changes/34/1234/567'])
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_mode_full_clean_different_project(self):
'HEAD', '--progress'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
command=['git', 'checkout', '-f', 'FETCH_HEAD'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'rev-parse', 'HEAD'])
Expand Down