From e02141fb80b85290c0ee6b3eab813740d5b0a1c7 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jun 05 2020 09:19:24 +0000 Subject: Suggest a way to track remote branch in the error log Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 1f9cce9..2ab2b98 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -370,7 +370,12 @@ class Commands(object): try: merge = self.repo.git.config('--get', 'branch.%s.merge' % localbranch) except git.GitCommandError: - raise rpkgError('Unable to find remote branch. Use --release') + msg = ( + 'Unable to find remote branch. Use --release\n' + 'If current branch has to track a remote branch, fix it with command:\n' + ' git branch -u origin/BRANCHNAME' + ) + raise rpkgError(msg) # Trim off the refs/heads so that we're just working with # the branch name merge = merge.replace('refs/heads/', '', 1) diff --git a/tests/test_commands.py b/tests/test_commands.py index d07508c..e52e23e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -182,7 +182,8 @@ class LoadBranchMergeTest(CommandTestCase): try: self.cmd.load_branch_merge() except rpkgError as e: - self.assertEqual('Unable to find remote branch. Use --release', str(e)) + self.assertIn('Unable to find remote branch. Use --release', str(e)) + self.assertIn('git branch -u origin/BRANCHNAME', str(e)) else: self.fail("It's expected to raise rpkgError, but not.")