mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Merge pull request #270 from stevekuznetsov/skuznets/better-undo
Do not undo tags when git state is dirty
This commit is contained in:
commit
10f5cfa0c2
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