mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
scripts: rfr: query gerrit for git sha1
The gerrit search supports git sha1 revisions, so use that directly when given a git commit. This changes the behaviour such that the change-id found from the commit message is not used implicitly, which removes ambiguity. Change-Id: Ifac1002421886dc73234b530d937395aae5addee Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1585437 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
b5b9e71bd5
commit
7e493175de
28
scripts/rfr
28
scripts/rfr
@@ -113,6 +113,13 @@ def commit_info_from_gerrit_change_id(change_id):
|
|||||||
|
|
||||||
return gerrit_query(change_id)
|
return gerrit_query(change_id)
|
||||||
|
|
||||||
|
def commit_info_from_git_sha1(rev):
|
||||||
|
"""
|
||||||
|
Return a dict with all the gerrit info from a git sha1 rev.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return gerrit_query(rev)
|
||||||
|
|
||||||
def commit_info_from_gerrit_cl(cmt):
|
def commit_info_from_gerrit_cl(cmt):
|
||||||
"""
|
"""
|
||||||
Return a dict with all the gerrit info from a Gerrit URL.
|
Return a dict with all the gerrit info from a Gerrit URL.
|
||||||
@@ -124,28 +131,21 @@ def commit_info_from_gerrit_cl(cmt):
|
|||||||
|
|
||||||
return gerrit_query(cl)
|
return gerrit_query(cl)
|
||||||
|
|
||||||
def gerrit_change_id_from_git_commit(cmt_id):
|
def git_sha1_from_commit(commit_ish):
|
||||||
"""
|
"""
|
||||||
Return the gerrit Change-Id from the passed git cmt_id. Returns None if
|
Return sha1 revision from a commit-ish string, or None if this doesn't
|
||||||
this doesn't appear to be a cmt_id or doesn't have a Change-Id line.
|
appear to be a commit.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cid_re = re.compile(r'Change-Id: (I[a-z0-9]{40})')
|
prog = subprocess.Popen('git rev-parse %s' % commit_ish, shell=True,
|
||||||
|
|
||||||
# First obtain the commit message itself.
|
|
||||||
prog = subprocess.Popen('git show --stat %s' % cmt_id, shell=True,
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
stdout_data, stderr_data = prog.communicate()
|
stdout_data, stderr_data = prog.communicate()
|
||||||
if prog.returncode != 0:
|
if prog.returncode != 0:
|
||||||
print('`git show %s\' failed?!' % cmt_id)
|
print('`git rev-parse %s\' failed?!' % commit_ish)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
m = cid_re.search(stdout_data.decode('utf-8'))
|
return stdout_data.decode('utf-8')
|
||||||
if m:
|
|
||||||
return m.group(1)
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def indent_lines(text, ind):
|
def indent_lines(text, ind):
|
||||||
"""
|
"""
|
||||||
@@ -220,7 +220,7 @@ def main():
|
|||||||
elif get_gerrit_url_id(cmt):
|
elif get_gerrit_url_id(cmt):
|
||||||
info = commit_info_from_gerrit_cl(cmt)
|
info = commit_info_from_gerrit_cl(cmt)
|
||||||
else:
|
else:
|
||||||
info = commit_info_from_gerrit_change_id(gerrit_change_id_from_git_commit(cmt))
|
info = commit_info_from_git_sha1(git_sha1_from_commit(cmt))
|
||||||
|
|
||||||
if info:
|
if info:
|
||||||
commits_info.append(info)
|
commits_info.append(info)
|
||||||
|
|||||||
Reference in New Issue
Block a user