sync_default_gems: Should match with the beginning of the strings

`git status -z` result is NUL-separated, and can contain newline
characters.
This commit is contained in:
Nobuyoshi Nakada 2022-10-12 11:38:44 +09:00
parent 04d291a490
commit c67e496886
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -478,13 +478,13 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
skipped = true
elsif /^CONFLICT/ =~ result
result = pipe_readlines(%W"git status --porcelain -z")
result.map! {|line| line[/^.U (.*)/, 1]}
result.map! {|line| line[/\A.U (.*)/, 1]}
result.compact!
ignore, conflict = result.partition {|name| IGNORE_FILE_PATTERN =~ name}
unless ignore.empty?
system(*%W"git reset HEAD --", *ignore)
File.unlink(*ignore)
ignore = pipe_readlines(%W"git status --porcelain -z" + ignore).map! {|line| line[/^.. (.*)/, 1]}
ignore = pipe_readlines(%W"git status --porcelain -z" + ignore).map! {|line| line[/\A.. (.*)/, 1]}
system(*%W"git checkout HEAD --", *ignore) unless ignore.empty?
end
unless conflict.empty?