ruby-changes:55931
From: Nobuyoshi <ko1@a...>
Date: Fri, 31 May 2019 10:56:24 +0900 (JST)
Subject: [ruby-changes:55931] Nobuyoshi Nakada: 1e9057b54a (trunk): Prefer the current branch or tag name
https://git.ruby-lang.org/ruby.git/commit/?id=1e9057b54a From 1e9057b54a53e7bc1fa3d0e3eaef1dd33707d044 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 31 May 2019 02:30:29 +0900 Subject: Prefer the current branch or tag name diff --git a/tool/vcs.rb b/tool/vcs.rb index 8379b3b..56924ff 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -408,8 +408,21 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L408 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 - branch_list.delete_if {|b| /detached at/ =~ b} - (branch = branch_list[0]).strip! unless branch_list.empty? + branch, = branch_list.grep(/\A\*/) + case branch + when /\A\* *\(\S+ detached at (.*)\)\Z/ + branch = $1 + branch = nil if last.start_with?(branch) + when /\A\* (\S+)\Z/ + branch = $1 + else + branch = nil + end + unless branch + branch_list.each {|b| b.strip!} + branch_list.delete_if {|b| / / =~ b} + branch = branch_list.min_by(&:length) || "" + end end branch.chomp! branch = ":detached:" if branch.empty? -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/