Skip to content

Fix the single file merge command #26

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions bin/phraseapp_updater
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,14 @@ class PhraseAppUpdaterCLI < Thor
validate_readable_file!('ancestor', ancestor)
validate_readable_file!('ours', ours)
validate_readable_file!('theirs', theirs)
validate_writable_file!('to', to)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge function uses

    result_path = options[:to]
    validate_writable_path!('to', result_path)

It seems nice to be be consistent, and also preserve the writable file check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate_writable_path! is perhaps misnamed, because it validates that it's an existing writable directory, which isn't helpful here. validate_writable_file! wouldn't be desirable either, because it likewise validates that it's an existing writable file.

What we'd ideally want here is validation that it's a path that could be written to (i.e. either a writable file or no existing file in a writable directory), which is something we haven't added to our library of helper function yet.


# Git provides an empty file when there is no common ancestor in the
# merge-base. Because we want to merge from an empty hash structure instead,
# pass `nil` to `merge_files`.
ancestor = nil if File.zero?(ancestor)

updater = PhraseAppUpdater.new(nil, nil, file_format, verbose: options[:verbose])
updater.merge_files(ours, theirs, ancestor, to)
updater = PhraseAppUpdater.new(nil, nil, options[:file_format], verbose: options[:verbose])
updater.merge_files(ours, theirs, ancestor, options[:to])
end

desc 'default', 'Prints gem information'
Expand Down
4 changes: 2 additions & 2 deletions lib/phraseapp_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def merge_files(ours, theirs, ancestor, result)
# Read the ancestor if provided
ancestor_file = load_locale_file(ancestor) unless ancestor.nil?

result_file = merge_locale_files(our_file, their_file, ancestor_file)
result_file = merge_locale_file(our_file, their_file, ancestor_file)

write_locale_file(result, result_file)
end
Expand Down Expand Up @@ -152,7 +152,7 @@ def load_locale_files(*filenames)
end
end

def load_local_file(filename)
def load_locale_file(filename)
@locale_file_class.load_file(filename)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/phraseapp_updater/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class PhraseAppUpdater
VERSION = '3.3.2'
VERSION = '3.3.3'
end
2 changes: 1 addition & 1 deletion nix/gem/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GEM
json (~> 2.1, >= 2.1.0)
link-header-parser (~> 4.0)
typhoeus (~> 1.0, >= 1.0.1)
phraseapp_updater (3.3.2)
phraseapp_updater (3.3.3)
concurrent-ruby (~> 1.0.2)
deep_merge (~> 1.2)
hashdiff (~> 1.0.1)
Expand Down
2 changes: 1 addition & 1 deletion nix/gem/gemset.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
sha256 = "1mrhphzf192m3sf43nm7ynpdz5mnmdwwq3hsvj9sf2j5rknv2nk5";
type = "gem";
};
version = "3.3.2";
version = "3.3.3";
};
pry = {
dependencies = ["coderay" "method_source"];
Expand Down
Loading