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

git hook: don't commit whole file #470

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

KotlinIsland
Copy link
Contributor

When you commit part of a file the current git hook will change your commit to being the entire file.

This pr stashes the worktree before fmt, and unstashed before finished

@Tapchicoma
Copy link
Collaborator

Could you add some test verifying this behaviour and update changelog?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Apr 20, 2021

@Tapchicoma Can you re-review this please.

Also, how do you build this project at all? I can only get pages of gradle errors and the steps in the readme didn't help.

@Tapchicoma
Copy link
Collaborator

Also, how do you build this project at all? I can only get pages of gradle errors and the steps in the readme didn't help.

If you want to run some test - best option is to open plugin/ subproject in IDEA, then run pluginUnderTestMetadata Gradle task (if you are using IDEA tests runner) or use Gradle tests runner.

Also sample project automatically apply all current changes from plugin subproject.

@@ -138,6 +138,30 @@ class GitHookTasksTest : AbstractPluginTest() {
}
}

@Test
internal fun `Format hook should not add non-indexed code to the commit`() {
// TODO: This test doesn't run git or verify that only indexed code is committed,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Too bad JGit does have partial staging 😒

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?

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.

LGTM!

Thank you for addressing this issue 👍

@GrahamBorland
Copy link

This updated precommit hook causes conflicts when you try to commit a badly-formatted change. See #497.

# 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.

3 participants