[PATCH compass-ci] auto_submit: add upstream_tag if the commit is tagged

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

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)
if_tagged这个名字不太合适,函数名称本身体现该函数是做什么 Thanks sunyukui
+ 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

On Tue, Oct 20, 2020 at 11:10:53AM +0800, Sun Yukui wrote:
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)
if_tagged这个名字不太合适,函数名称本身体现该函数是做什么
It means 'if it is tagged?' That is what the method do, just check if the commit is tagged. Thanks, Yuanchao

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)
if_tagged => find_tag? Thanks, Xueliang
+ 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

On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag. Thanks, Yuanchao

On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id) better. Thanks, Zhang Yuhang

On Tue, Oct 20, 2020 at 03:00:50PM +0800, Zhang Yuhang wrote:
On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id)
better.
Thanks, Zhang Yuhang
good idea! just like File.size? , It's more easy to understand. Thanks, Kaiyi

On Tue, Oct 20, 2020 at 03:00:50PM +0800, Zhang Yuhang wrote:
On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id)
Yes, it's a good advice. Thanks Thanks, Yuanchao

On Tue, Oct 20, 2020 at 03:36:02PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 03:00:50PM +0800, Zhang Yuhang wrote:
On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id)
Yes, it's a good advice. Thanks
"some_func?" should return true/false. Is it the case here? Thanks, Fengguang

On Tue, Oct 20, 2020 at 04:02:06PM +0800, Wu Fengguang wrote:
On Tue, Oct 20, 2020 at 03:36:02PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 03:00:50PM +0800, Zhang Yuhang wrote:
On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id)
Yes, it's a good advice. Thanks
"some_func?" should return true/false. Is it the case here?
No. Maybe 'check_tag'? Good name is really a challenge Thanks, Yuanchao

On Tue, Oct 20, 2020 at 04:17:03PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 04:02:06PM +0800, Wu Fengguang wrote:
On Tue, Oct 20, 2020 at 03:36:02PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 03:00:50PM +0800, Zhang Yuhang wrote:
On Tue, Oct 20, 2020 at 02:41:39PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 11:18:30AM +0800, Cao Xueliang wrote:
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)
if_tagged => find_tag?
find_tag maybe not suitable. I mean, it is to check if the commit is tagged, not to find a tag.
Thanks, Yuanchao
def tagged?(tag_list, commit_id)
Yes, it's a good advice. Thanks
"some_func?" should return true/false. Is it the case here?
No. Maybe 'check_tag'? Good name is really a challenge
Thanks, Yuanchao
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 tag = if_tagged(tag_list, commit_id) real_argvs.push("upstream_tag=#{tag}") if tag The function will return string or nil. Then return the value to variable "tag". Could we just use "get_tag"? Thanks, Zhang Yuhang

On Tue, Oct 20, 2020 at 03:40:18PM +0800, Li Yuanchao wrote:
On Tue, Oct 20, 2020 at 02:35:36PM +0800, Lu Weitao wrote:
On Tue, Oct 20, 2020 at 10:58:51AM +0800, Li Yuanchao wrote:
add upstream_tag to what?
To the job.yaml
got it.
will save the field to ES DB?
Maybe not. You may need to add label in es first to save it in es
ok Thanks, Weitao
Thanks, Yuanchao

前期调研不够给力。 这个可以大幅简化逻辑: 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

On Tue, Oct 20, 2020 at 03:16:49PM +0800, Wu Fengguang wrote:
前期调研不够给力。 这个可以大幅简化逻辑:
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...
Yes, it's a good way. Thanks Thanks, Yuanchao
participants (7)
-
Cao Xueliang
-
Li Yuanchao
-
Lu Kaiyi
-
Lu Weitao
-
Sun Yukui
-
Wu Fengguang
-
Zhang Yuhang