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

ruby-changes:57394

From: Nobuyoshi <ko1@a...>
Date: Fri, 30 Aug 2019 11:24:34 +0900 (JST)
Subject: [ruby-changes:57394] Nobuyoshi Nakada: 55f496c89b (master): Support revision in git-svn log

https://git.ruby-lang.org/ruby.git/commit/?id=55f496c89b

From 55f496c89b820f57d9e07c744675da8c43d6aa46 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 30 Aug 2019 10:14:15 +0900
Subject: Support revision in git-svn log


diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index db8b91e..e38db07 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -252,12 +252,16 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L252
   def after_export(dir)
   end
 
+  def revision_handler(rev)
+    self.class
+  end
+
   def revision_name(rev)
-    self.class.revision_name(rev)
+    revision_handler(rev).revision_name(rev)
   end
 
   def short_revision(rev)
-    self.class.short_revision(rev)
+    revision_handler(rev).short_revision(rev)
   end
 
   class SVN < self
@@ -446,12 +450,26 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L450
       cmd_read_at(@srcdir, cmds)
     end
 
+    def svn_revision(log)
+      if /^ *git-svn-id: .*@(\d+) .*\n+\z/ =~ log
+        $1.to_i
+      end
+    end
+
     def _get_revisions(path, srcdir = nil)
       gitcmd = [COMMAND]
       last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip
       log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', '--pretty=fuller', *path]])
       changed = log[/\Acommit (\h+)/, 1]
       modified = log[/^CommitDate:\s+(.*)/, 1]
+      if rev = svn_revision(log)
+        if changed == last
+          last = rev
+        else
+          last = svn_revision(cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--format=%B', last]]))
+        end
+        changed = rev
+      end
       branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]])
       if branch.empty?
         branch_list = cmd_read_at(srcdir, [gitcmd + %W[branch --list --contains HEAD]]).lines.to_a
@@ -488,6 +506,15 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L506
       rev[0, 10]
     end
 
+    def revision_handler(rev)
+      case rev
+      when Integer
+        SVN
+      else
+        super
+      end
+    end
+
     def without_gitconfig
       home = ENV.delete('HOME')
       yield
@@ -627,10 +654,6 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L654
       SVN.revision_name(rev)
     end
 
-    def self.short_revision(rev)
-      SVN.short_revision(rev)
-    end
-
     def format_changelog(r, path)
       open(path, 'w') do |w|
         sep = "-"*72
-- 
cgit v0.10.2


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

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