前期调研不够给力。 这个可以大幅简化逻辑:
wfg /c/linux% git tag --points-at f4d51dffc6c01a9e94650d95ce0104964f8ae822|cat v5.9-rc4
Just google "git get tag of a commit"
https://stackoverflow.com/questions/2324195/how-to-get-tags-on-current-commi...
Thanks, Fengguang
On Tue, Oct 20, 2020 at 10:58:51AM +0800, Li Yuanchao wrote:
sometimes the testcase needs a specific version software, add upstream_tag can help find the specific version.
Signed-off-by: Li Yuanchao lyc163mail@163.com
sbin/auto_submit | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/sbin/auto_submit b/sbin/auto_submit index 1f55701..88ec560 100755 --- a/sbin/auto_submit +++ b/sbin/auto_submit @@ -28,12 +28,25 @@ class AutoSubmit return pkgbuild_repo end
def if_tagged(tag_list, commit_id)
tag_list.each_line do |line|
if line.include?(commit_id)
tag = line.split
return tag[1].delete_prefix('refs/tags/')
end
end
return nil
end
def submit(newrefs_info, submit_argv)
tag_list = %x(git -C /srv/git/#{newrefs_info['git_repo']}.git show-ref --tags) newrefs_info['new_refs']['heads'].each do |branch, commit_id| real_argvs = Array.new(submit_argv) commit_date = `git -C /srv/git/#{newrefs_info['git_repo']}.git log --format=%ct -1 #{commit_id}` real_argvs.push("upstream_branch=#{branch.delete_prefix('refs/heads/')}") real_argvs.push("upstream_commit=#{commit_id}")
tag = if_tagged(tag_list, commit_id)
real_argvs.push("upstream_tag=#{tag}") if tag real_argvs.push("commit_date=#{commit_date}") system(real_argvs.join(' '))
-- 2.23.0