Skip to content

Commit

Permalink
Fix feature prefixing
Browse files Browse the repository at this point in the history
In some cases, specifically in `sj up`, we might double-prefix
a branch name. This unifies the logic and then checks for that.

Signed-off-by: Phil Dibowitz <phil@ipom.com>
  • Loading branch information
jaymzh committed Mar 22, 2024
1 parent ab5ca27 commit 2fe5c4c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/sugarjar/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def subfeature(name)
def bclean(name = nil)
assert_in_repo
name ||= current_branch
name = fprefix(name) unless all_local_branches.include?(name)
name = fprefix(name)
if clean_branch(name)
SugarJar::Log.info("#{name}: #{color('reaped', :green)}")
else
Expand Down Expand Up @@ -112,7 +112,7 @@ def co(*args)
# and then add any featureprefix, and if _that_ is a branch
# name, replace the last arguement with that
name = args.last
bname = fprefix(name) unless all_local_branches.include?(name)
bname = fprefix(name)
if all_local_branches.include?(bname)
SugarJar::Log.debug("Featurepefixing #{name} -> #{bname}")
args[-1] = bname
Expand Down Expand Up @@ -403,6 +403,9 @@ def pullsuggestions
def fprefix(name)
return name unless @feature_prefix

return name if name.starts_with?(@feature_prefix)
return name if all_local_branches.include?(name)

newname = "#{@feature_prefix}#{name}"
SugarJar::Log.debug(
"Munging feature name: #{name} -> #{newname} due to feature prefix",
Expand Down

0 comments on commit 2fe5c4c

Please sign in to comment.