Skip to content

Commit

Permalink
Handle parent feature going away
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymzh committed Apr 26, 2024
1 parent 67a0190 commit 63c69b5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/sugarjar/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,17 @@ def gitup
SugarJar::Log.debug('Fetching upstream')
fetch_upstream
curr = current_branch
base = tracked_branch
# this isn't a hash, it's a named param, silly rubocop
# rubocop:disable Style/HashSyntax
base = tracked_branch(fallback: false)
# rubocop:enable Style/HashSyntax
unless base
Sugarjar::Log.warn(
'The brach we were tracking is gone, resetting tracking to ' +
most_main,
)
git('branch', '-u', base)
end
# If this is a subfeature based on a local branch which has since
# been deleted, 'tracked branch' will automatically return <most_main>
# so we don't need any special handling for that
Expand Down Expand Up @@ -886,12 +896,13 @@ def rebase_in_progress?
File.exist?(rebase_file) || File.exist?(rebase_merge_file)
end

def tracked_branch
def tracked_branch(fallback: true)
s = git_nofail(
'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'
)
if s.error?
most_main
fallback ? most_main : nil

else
s.stdout.strip
end
Expand Down

0 comments on commit 63c69b5

Please sign in to comment.