Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/11757
Change subject: gits: remove code dup: ask_reset_hard() ...................................................................... gits: remove code dup: ask_reset_hard() The diff may look a bit weird, but this really just moves a bit of code that existed twice into a local function. Change-Id: I741aa6ca29370f26a724f5b4b9c6e7f8ac3f282a --- M src/gits 1 file changed, 11 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/57/11757/1 diff --git a/src/gits b/src/gits index 681082d..bd3e3f2 100755 --- a/src/gits +++ b/src/gits @@ -269,12 +269,8 @@ print('There still are local modifications') raise SkipThisRepo() - # Missing upstream branch - if not upstream_branch: - print('there is no upstream branch for %r' % orig_branch) - # Diverged - elif ahead and behind: + def ask_reset_hard(): do_reset = ask(git_dir, 'Diverged.', '%s: git reset --hard %s?' % ( orig_branch, upstream_branch), @@ -285,6 +281,15 @@ if do_reset == 'OK': git(git_dir, 'reset', '--hard', upstream_branch) + + # Missing upstream branch + if not upstream_branch: + print('there is no upstream branch for %r' % orig_branch) + + # Diverged + elif ahead and behind: + ask_reset_hard() + # Behind elif behind: if git_can_fast_forward(git_dir, orig_branch, upstream_branch): @@ -311,13 +316,7 @@ git(git_dir, 'commit', '-am', 'wip', may_fail=True) git(git_dir, 'checkout', orig_branch) - do_reset = ask(git_dir, '%s: git reset --hard %s?' % (orig_branch, upstream_branch), - '<empty> no', - 'OK yes (write OK in caps!)', - valid_answers=('', 'OK')) - - if do_reset == 'OK': - git(git_dir, 'reset', '--hard', upstream_branch) + ask_reset_hard() return orig_branch -- To view, visit https://gerrit.osmocom.org/11757 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I741aa6ca29370f26a724f5b4b9c6e7f8ac3f282a Gerrit-Change-Number: 11757 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>