Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve pre-commit hook causing conflicts #502

Merged
merged 1 commit into from
Jun 16, 2021

Conversation

KotlinIsland
Copy link
Contributor

resolves #497

The logic was using git stash push --keep-index which keeps the index but also adds it to the stash. I've change the functionality to use a .diff file with the changes git diff > unstaged.diff and reapply it with git apply --ignore-whitespace unstaged.diff, in my opinion using -3 would be better but then git applies it to the index, not the working copy.

There isn't a current version in the changes so I bumped it to 10.1.1

Copy link
Collaborator

@Tapchicoma Tapchicoma left a comment

Choose a reason for hiding this comment

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

Could you rebase your PR against master and put your changes into '[Unreleased]' changelog section?

@@ -157,8 +157,10 @@ class GitHookTasksTest : AbstractPluginTest() {
build(":$INSTALL_GIT_HOOK_FORMAT_TASK").run {
assertThat(task(":$INSTALL_GIT_HOOK_FORMAT_TASK")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
val hookText = gitDir.preCommitGitHook().readText()
assertThat(hookText).contains("git stash push")
assertThat(hookText).contains("git stash pop")
assertThat(hookText).contains("git diff > unstaged.diff")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am really need to come up with git hook test setup that actually runs installed githook on some test project 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KotlinIsland
Copy link
Contributor Author

Only thing i don't like is if the patch fails to apply after format, ignore-whitespace will help but is that good enough?

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

Successfully merging this pull request may close these issues.

Precommit hook causes conflicts and doesn't commit changes
2 participants