mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Do not undo tags when git state is dirty
When using `tito tag --undo` in a repository with a dirty `git` state, no action should be taken. Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
parent
26219abfde
commit
ce7cb5b3c7
1 changed files with 18 additions and 0 deletions
|
@ -544,12 +544,30 @@ def undo_tag(tag):
|
|||
commit. Assumes you have taken necessary precautions to ensure this is
|
||||
what you want to do.
|
||||
"""
|
||||
if not is_git_state_clean():
|
||||
error_out("Cannot undo a tag when the current git state is not clean!")
|
||||
|
||||
# Using --merge here as it appears to undo the changes in the commit,
|
||||
# but preserve any modified files:
|
||||
output = run_command("git tag -d %s && git reset --merge HEAD^1" % tag)
|
||||
print(output)
|
||||
|
||||
|
||||
def is_git_state_clean():
|
||||
"""
|
||||
Determines if the state of the current git repository is clean or not.
|
||||
"""
|
||||
(status, _) = getstatusoutput("git diff-index --quiet HEAD")
|
||||
if status != 0:
|
||||
return False
|
||||
|
||||
(status, output) = getstatusoutput("git ls-files --exclude-standard --others")
|
||||
if len(output) > 0 or status > 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_remote_tag_sha1(tag):
|
||||
"""
|
||||
Get the SHA1 referenced by this git tag in the remote git repo.
|
||||
|
|
Loading…
Add table
Reference in a new issue