[前][次][番号順一覧][スレッド一覧]

ruby-changes:62192

From: Nobuyoshi <ko1@a...>
Date: Mon, 13 Jul 2020 00:35:34 +0900 (JST)
Subject: [ruby-changes:62192] 162d08b854 (master): sync_default_gems.rb: Added -e option to edit when conflicted

https://git.ruby-lang.org/ruby.git/commit/?id=162d08b854

From 162d08b8541167a089b2c504d3437b577c38c3f9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 12 Jul 2020 23:40:27 +0900
Subject: sync_default_gems.rb: Added -e option to edit when conflicted


diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index da41f1a..4cd8ddb 100644
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -313,7 +313,7 @@ end https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L313
 
 IGNORE_FILE_PATTERN = /\A(?:\.travis.yml|appveyor\.yml|azure-pipelines\.yml|\.git(?:ignore|hub)|Gemfile|README\.md|History\.txt|Rakefile|CODE_OF_CONDUCT\.md)/
 
-def sync_default_gems_with_commits(gem, ranges)
+def sync_default_gems_with_commits(gem, ranges, edit: nil)
   puts "Sync #{$repositories[gem.to_sym]} with commit history."
 
   IO.popen(%W"git remote") do |f|
@@ -363,12 +363,24 @@ def sync_default_gems_with_commits(gem, ranges) https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L363
       skipped = true
     elsif /^CONFLICT/ =~ result
       result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!)
-      ignore = result.map {|line| /^.U / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name}
-      ignore.compact!
+      result.map! {|line| line[/^.U (.*)/, 1]}
+      result.compact!
+      ignore, conflict = result.partition {|name| IGNORE_FILE_PATTERN =~ name}
       unless ignore.empty?
         system(*%W"git reset HEAD --", *ignore)
         system(*%W"git checkout HEAD --", *ignore)
       end
+      unless conflict.empty?
+        if edit
+          case
+          when (editor = ENV["GIT_EDITOR"] and !editor.empty?)
+          when (editor = `git config core.editor` and (editor.chomp!; !editor.empty?))
+          end
+          if editor
+            system([editor, conflict].join(' '))
+          end
+        end
+      end
       skipped = !system({"GIT_EDITOR"=>"true"}, *%W"git cherry-pick --no-edit --continue")
     end
 
@@ -469,9 +481,13 @@ when nil, "-h", "--help" https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L481
 
   exit
 else
+  if ARGV[0] == "-e"
+    edit = true
+    ARGV.shift
+  end
   gem = ARGV.shift
   if ARGV[0]
-    sync_default_gems_with_commits(gem, ARGV)
+    sync_default_gems_with_commits(gem, ARGV, edit: edit)
   else
     sync_default_gems(gem)
   end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]