Skip to content
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

Fix pre-commit skip hook checks #3532

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Fix pre-commit skip hook checks #3532

wants to merge 2 commits into from

Conversation

mark2185
Copy link
Collaborator

  • PR Description
    This tests for pre-commit hooks in several previously unchecked situations, e.g. when amending, rewording, (re)setting the author, extracting custom patch to a new commit.

It's a draft because I haven't implemented all of those yet and because those that have been implemented haven't yet been added as tests (some have, some haven't).

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • Docs (specifically docs/Config.md) have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like how you add the failing test first. 😄

This is not a review yet, since is still a draft; just two early thoughts below.

@@ -22,7 +22,13 @@ func NewCommitCommands(gitCommon *GitCommon) *CommitCommands {

// ResetAuthor resets the author of the topmost commit
func (self *CommitCommands) ResetAuthor() error {
message, err := self.GetCommitMessage("HEAD")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit wasteful to ask git for the commit message here when we have it in our model in memory already. Maybe we should pass in either the subject or a skipHook bool into this function (and the other ones below).

return self.cmd.New(NewGitCmd("commit").Arg("--allow-empty", "--amend", "--only").ToArgv())

return self.cmd.New(NewGitCmd("commit").
// TODO: how to decide if we should add --no-verify if we're using the editor?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the best we can do is to decide based on the existing subject and hope they don't change it in the editor. Either that, or just never pass --no-verify in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants