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

Handle parent feature going away #159

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading