Skip to content

Only check staged content in pre-hooks#916

Draft
Emilgardis wants to merge 2 commits into
cross-rs:mainfrom
Emilgardis:hook-stash
Draft

Only check staged content in pre-hooks#916
Emilgardis wants to merge 2 commits into
cross-rs:mainfrom
Emilgardis:hook-stash

Conversation

@Emilgardis
Copy link
Copy Markdown
Member

No description provided.

@Emilgardis Emilgardis force-pushed the hook-stash branch 4 times, most recently from 1ded0d8 to 4aa88c0 Compare July 6, 2022 13:56
@Emilgardis Emilgardis added the no changelog A valid PR without changelog (no-changelog) label Jul 6, 2022
@Emilgardis Emilgardis marked this pull request as ready for review July 6, 2022 14:02
@Emilgardis Emilgardis requested a review from a team as a code owner July 6, 2022 14:02
Comment thread xtask/src/pre-commit.sh
git diff --full-index --binary > "$tf"
git stash -q --keep-index

trap cleanup EXIT
Copy link
Copy Markdown
Contributor

@Alexhuszagh Alexhuszagh Jul 6, 2022

Choose a reason for hiding this comment

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

This won't work on SIGKILL or SIGSTOP, which would lead to data lost. It also doesn't work for new files, which would mean they would be tests but not staged. There probably needs to be some means of recover (consistent file naming, a script to undo the last action in the Git history, something).

Copy link
Copy Markdown
Contributor

@Alexhuszagh Alexhuszagh Jul 6, 2022

Choose a reason for hiding this comment

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

A simple example is:

$ echo "Sample contents" > file
$ git diff --full-index --binary # no output
$ git stash -q --keep-index      # doesn't stash anything

@Emilgardis Emilgardis marked this pull request as draft July 9, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog A valid PR without changelog (no-changelog)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants