mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Extract pipe_readlines
method which reads from the pipeline
This commit is contained in:
parent
b09e96341e
commit
a3ef0746ce
1 changed files with 9 additions and 5 deletions
|
@ -77,6 +77,12 @@ REPOSITORIES = {
|
||||||
win32ole: "ruby/win32ole",
|
win32ole: "ruby/win32ole",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def pipe_readlines(args, rs: "\0", chomp: true)
|
||||||
|
IO.popen(args) do |f|
|
||||||
|
f.readlines(rs, chomp: chomp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# We usually don't use this. Please consider using #sync_default_gems_with_commits instead.
|
# We usually don't use this. Please consider using #sync_default_gems_with_commits instead.
|
||||||
def sync_default_gems(gem)
|
def sync_default_gems(gem)
|
||||||
repo = REPOSITORIES[gem.to_sym]
|
repo = REPOSITORIES[gem.to_sym]
|
||||||
|
@ -424,9 +430,7 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
|
||||||
|
|
||||||
# Ignore Merge commit and insufficiency commit for ruby core repository.
|
# Ignore Merge commit and insufficiency commit for ruby core repository.
|
||||||
commits.delete_if do |sha, subject|
|
commits.delete_if do |sha, subject|
|
||||||
files = IO.popen(%W"git diff-tree -z --no-commit-id --name-only -r #{sha}") {|f|
|
files = pipe_readlines(%W"git diff-tree -z --no-commit-id --name-only -r #{sha}")
|
||||||
f.readlines("\0", chomp: true)
|
|
||||||
}
|
|
||||||
subject.start_with?("Merge", "Auto Merge") or files.all?(IGNORE_FILE_PATTERN)
|
subject.start_with?("Merge", "Auto Merge") or files.all?(IGNORE_FILE_PATTERN)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -464,14 +468,14 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
|
||||||
if result.empty?
|
if result.empty?
|
||||||
skipped = true
|
skipped = true
|
||||||
elsif /^CONFLICT/ =~ result
|
elsif /^CONFLICT/ =~ result
|
||||||
result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!)
|
result = pipe_readlines(%W"git status --porcelain -z")
|
||||||
result.map! {|line| line[/^.U (.*)/, 1]}
|
result.map! {|line| line[/^.U (.*)/, 1]}
|
||||||
result.compact!
|
result.compact!
|
||||||
ignore, conflict = result.partition {|name| IGNORE_FILE_PATTERN =~ name}
|
ignore, conflict = result.partition {|name| IGNORE_FILE_PATTERN =~ name}
|
||||||
unless ignore.empty?
|
unless ignore.empty?
|
||||||
system(*%W"git reset HEAD --", *ignore)
|
system(*%W"git reset HEAD --", *ignore)
|
||||||
File.unlink(*ignore)
|
File.unlink(*ignore)
|
||||||
ignore = IO.popen(%W"git status --porcelain" + ignore, &:readlines).map! {|line| line[/^.. (.*)/, 1]}
|
ignore = pipe_readlines(%W"git status --porcelain -z" + ignore).map! {|line| line[/^.. (.*)/, 1]}
|
||||||
system(*%W"git checkout HEAD --", *ignore) unless ignore.empty?
|
system(*%W"git checkout HEAD --", *ignore) unless ignore.empty?
|
||||||
end
|
end
|
||||||
unless conflict.empty?
|
unless conflict.empty?
|
||||||
|
|
Loading…
Add table
Reference in a new issue