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 9e97b6a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/sugarjar/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,18 @@ 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.info(
'The brach we were tracking is gone, resetting tracking to ' +
most_main,
)
git('branch', '-u', most_main)
base = most_main
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 +897,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 9e97b6a

Please sign in to comment.