-
-
Notifications
You must be signed in to change notification settings - Fork 281
WIP: Fix/issue 251 #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Fix/issue 251 #279
Conversation
The last version could not handle tags order by [0.3.0, 0.3.0a0, ...], it would try to delete 0.3.0a0
Nice, thanks for this 👍 Could you include a new command documentation in We are working on fixing the CI issue. |
commitizen/cli.py
Outdated
"func": commands.Undo, | ||
"arguments": [ | ||
{ | ||
"name": ["--bump"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of adding a shortcut here? -b
and -c
for commit?
We'd have cz undo -b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great 💯
Sure~ 👍 |
@Sirius207 Even though we're working on the CI issue, would you help us ignore |
OK 👍 |
Codecov Report
@@ Coverage Diff @@
## master #279 +/- ##
==========================================
- Coverage 96.58% 96.37% -0.21%
==========================================
Files 33 34 +1
Lines 908 966 +58
==========================================
+ Hits 877 931 +54
- Misses 31 35 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
||
|
||
class Undo: | ||
"""Reset the latest git commit or git tag.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we use various terms for the same meaning (i.e., reset / revert / undo). I'll suggest unifying them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use "undo". 👌
self.arguments = arguments | ||
|
||
def _get_bump_command(self): | ||
created_tag = git.get_latest_tag() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this one named as created_tag
instead of latest_tag
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The created_tag
is original name and get_latest_tag
comes later, I would use latest_tag
in next commit. 👍
commits = git.get_commits() | ||
|
||
if created_tag and commits: | ||
created_commit = commits[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the question above
return command | ||
|
||
def __call__(self): | ||
bump: bool = self.arguments.get("bump") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
doesn't seem to be clear enough to me. How about something like reverting_bump
?
if bump: | ||
command = self._get_bump_command() | ||
elif commit: | ||
command = "git reset HEAD~" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes we'll encounter the situation that we don't have HEAD
. Will it be possible for us to solve that situation?
out.error(c.err) | ||
|
||
out.write(c.out) | ||
out.success("Undo successful!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Succeeded on undoning!
or Undo successfully!
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the latter 👍
Will use documentation for now, closing this |
Description
Follow the discussion of #251, I add the following command.
Checklist
./script/format
and./script/test
locally to ensure this change passes linter check and testExpected behavior
cz undo --bump
: delete the latest tag and the related commitcz undo --commit
: reset the latest commitSteps to Test This Pull Request
cz undo --bump
cz bump
cz undo --bump
cz undo --commit
cz commit
cz undo --commit
Additional context
If I execute the following statements first, the



git.get_tags()
would get the tags order by[0.3.0a0, 0.3.0, ...]
.So I implement another function
git.get_latest_tag()