In support of adding link trailers as git notes, factor out
git_get_rev_diff() for reuse.

Signed-off-by: Dan Williams <[email protected]>
---
 src/b4/__init__.py | 5 +++++
 src/b4/ty.py       | 7 +------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index c608a4d7956a..c2cdb028fa54 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -2932,6 +2932,11 @@ def in_directory(dirname: str) -> Generator[bool, None, 
None]:
         os.chdir(cdir)
 
 
+def git_get_rev_diff(gitdir: Optional[str], rev: str) -> Tuple[int, str]:
+    args = ['diff', '%s~..%s' % (rev, rev)]
+    return git_run_command(gitdir, args)
+
+
 def setup_config(cmdargs: argparse.Namespace) -> None:
     """Setup configuration options. Needs to be called before accessing any of
     the config options."""
diff --git a/src/b4/ty.py b/src/b4/ty.py
index 9f01bd534c74..8d41a22e536b 100644
--- a/src/b4/ty.py
+++ b/src/b4/ty.py
@@ -70,11 +70,6 @@ def git_get_merge_id(gitdir: Optional[str], commit_id: str, 
branch: Optional[str
     return lines[-1]
 
 
-def git_get_rev_diff(gitdir: Optional[str], rev: str) -> Tuple[int, str]:
-    args = ['diff', '%s~..%s' % (rev, rev)]
-    return b4.git_run_command(gitdir, args)
-
-
 def git_get_commit_message(gitdir: Optional[str], rev: str) -> Tuple[int, str]:
     args = ['log', '--format=%B', '-1', rev]
     return b4.git_run_command(gitdir, args)
@@ -191,7 +186,7 @@ def get_all_commits(gitdir: Optional[str], branch: str, 
since: str = '1.week',
     # Get patch hash of each commit
     for line in lines:
         commit_id, subject = line.split(maxsplit=1)
-        ecode, out = git_get_rev_diff(gitdir, commit_id)
+        ecode, out = b4.git_get_rev_diff(gitdir, commit_id)
         pwhash = b4.LoreMessage.get_patchwork_hash(out)
         logger.debug('phash=%s', pwhash)
         # get all message-id or link trailers
-- 
2.51.0


Reply via email to