Skip to content

Commit

Permalink
kintsugi: Fix passing options from install-driver to driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
byohay committed Apr 9, 2023
1 parent a485c50 commit 99b018f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/kintsugi/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,10 @@ def create_driver_subcommand
end

def create_install_driver_subcommand
option_parser =
OptionParser.new do |opts|
opts.banner = "Usage: kintsugi install-driver [driver-options]\n" \
"Installs Kintsugi as a Git merge driver globally. `driver-options` will be passed " \
"to `kintsugi driver`."

opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end
option_parser = create_driver_subcommand.option_parser
option_parser.banner = "Usage: kintsugi install-driver [driver-options]\n" \
"Installs Kintsugi as a Git merge driver globally. `driver-options` will be passed " \
"to `kintsugi driver`."

action = lambda { |options, arguments|
if arguments.count != 0
Expand All @@ -94,7 +87,12 @@ def create_install_driver_subcommand
exit(1)
end

install_kintsugi_driver_globally(options)
driver_options = options.map do |key, value|
prefix = key.length > 1 ? "--" : "-"
[prefix + key.to_s, value]
end.flatten

install_kintsugi_driver_globally(driver_options)
puts "Done! 🪄"
}

Expand All @@ -106,8 +104,9 @@ def create_install_driver_subcommand
end

def install_kintsugi_driver_globally(options)
joined_options = options.count > 1 ? " #{options.join(" ")}" : ""
`git config --global merge.kintsugi.name "Kintsugi driver"`
kintsugi_command = "kintsugi driver %O %A %B %P #{options}"
kintsugi_command = "kintsugi driver %O %A %B %P#{joined_options}"
`git config --global merge.kintsugi.driver "#{kintsugi_command}"`

attributes_file_path = global_attributes_file_path
Expand Down

0 comments on commit 99b018f

Please sign in to comment.