git_deploy: only return tags merged in the remote branch

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-07-13 10:30:39 -04:00
parent 0437d1623e
commit db27fef6f2
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 5 additions and 3 deletions

View File

@ -962,11 +962,13 @@ class GitRepo:
return commits_behind return commits_behind
async def get_tagged_commits(self, count: int = 100) -> Dict[str, str]: async def get_tagged_commits(self, count: int = 100) -> Dict[str, str]:
self._verify_repo() self._verify_repo(check_remote=True)
tip = f"{self.git_remote}/{self.git_branch}"
cnt_arg = f"--count={count} " if count > 0 else ""
async with self.git_operation_lock: async with self.git_operation_lock:
resp = await self._run_git_cmd( resp = await self._run_git_cmd(
f"for-each-ref --count={count} --sort='-creatordate' " f"for-each-ref {cnt_arg}--sort='-creatordate' --contains=HEAD "
f"--contains=HEAD --format={GIT_REF_FMT} 'refs/tags'" f"--merged={tip} --format={GIT_REF_FMT} 'refs/tags'"
) )
tagged_commits: Dict[str, str] = {} tagged_commits: Dict[str, str] = {}
for line in resp.split('\n'): for line in resp.split('\n'):