[14/15] git-tracker: refactor function that adds change-id
diff mbox series

Message ID 20200221095437.c04553d91428.I5895c66b1942b16096979ea5bc1e38a4d9caaa75@changeid
State New
Headers show
Series
  • updates & improvements
Related show

Commit Message

Johannes Berg Feb. 21, 2020, 8:56 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 devel/git-tracker.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/devel/git-tracker.py b/devel/git-tracker.py
index 7e55fa5ccb8e..14e2f14b9a63 100755
--- a/devel/git-tracker.py
+++ b/devel/git-tracker.py
@@ -54,6 +54,16 @@  def update_cache_objects(gittree, objdir, input):
         git.set_origin(gittree, objdir)
         git.remote_update(objdir, env=env)
 
+def add_changeid_to_message(msg):
+    have_changeid = False
+    for line in msg.split('\n'):
+        if line.lower().startswith('change-id: I'):
+            have_changeid = True
+            break
+    if not have_changeid:
+        msg += 'Change-Id: I%s\n' % hashlib.sha1(msg).hexdigest()
+    return msg
+
 def handle_commit(args, msg, branch, treename, kernelobjdir, tmpdir, wgitdir, backport_rev, kernel_rev,
                   prev_kernel_rev=None, defconfig=None, env={}, commit_failure=True,
                   append_shortlog=None, add_changeid=False):
@@ -129,13 +139,7 @@  def handle_commit(args, msg, branch, treename, kernelobjdir, tmpdir, wgitdir, ba
           }
 
             if add_changeid:
-                have_changeid = False
-                for line in msg.split('\n'):
-                    if line.lower().startswith('change-id: I'):
-                        have_changeid = True
-                        break
-                if not have_changeid:
-                    msg += 'Change-Id: I%s\n' % hashlib.sha1(msg).hexdigest()
+                msg = add_changeid_to_message(msg)
 
             treeid = git.write_tree(tree=wdir)
             git.commit_tree(treeid, msg, parents, tree=wdir, env=env)