diff --git a/pym/bob/scm/git.py b/pym/bob/scm/git.py index 06002f60c..6b762e25a 100644 --- a/pym/bob/scm/git.py +++ b/pym/bob/scm/git.py @@ -695,18 +695,15 @@ def status(self, workspacePath): status.add(ScmTaint.switched, "> commit: configured: '{}', actual: '{}'".format(self.__commit, output)) elif self.__tag: - output = self.callGit(workspacePath, 'tag', '--points-at', 'HEAD').splitlines() - if self.__tag not in output: + currentCommit = self.callGit(workspacePath, 'rev-parse', 'HEAD') + tagCommit = self.callGit(workspacePath, 'rev-parse', + 'refs/tags/'+self.__tag+'^{commit}', + check=False) + if (not currentCommit) or (currentCommit != tagCommit): + output = self.callGit(workspacePath, 'tag', '--points-at', 'HEAD').splitlines() actual = ("'" + ", ".join(output) + "'") if output else "not on any tag" status.add(ScmTaint.switched, "> tag: configured: '{}', actual: {}".format(self.__tag, actual)) - - # Need to check if the tag still exists. Otherwise the "git - # log" command at the end will trip. - try: - self.callGit(workspacePath, 'rev-parse', 'tags/'+self.__tag) - except BuildError: - pass elif self.__branch: output = self.callGit(workspacePath, 'rev-parse', '--abbrev-ref', 'HEAD') if output != self.__branch: diff --git a/test/unit/test_input_gitscm_status.py b/test/unit/test_input_gitscm_status.py index 493017348..671ede73a 100644 --- a/test/unit/test_input_gitscm_status.py +++ b/test/unit/test_input_gitscm_status.py @@ -147,6 +147,14 @@ def testOrphanedOk(self): s = self.statusGitScm({ 'tag' : 'v1.1' }) self.assertEqual(s.flags, set()) + def testNestedTagOk(self): + self.callGit('git fetch origin tag v1.1', cwd=self.repodir_local) + self.callGit('git tag -a -m nested nested v1.1', cwd=self.repodir_local) + self.callGit('git tag -a -m double double nested', cwd=self.repodir_local) + self.callGit('git checkout tags/double', cwd=self.repodir_local) + s = self.statusGitScm({ 'tag' : 'double' }) + self.assertEqual(s.flags, set()) + class TestSubmodulesStatus(TestCase):