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

Respect pre-commit hooks #48

Open
joao-p-marques opened this issue Sep 16, 2021 · 7 comments
Open

Respect pre-commit hooks #48

joao-p-marques opened this issue Sep 16, 2021 · 7 comments
Labels
upstream Blocked on upstream libgit2/git2rs

Comments

@joao-p-marques
Copy link

Hi! 👋

First of all, thanks for the great project.

I am finding that, when running the command, it does not follow any hooks I have defined for the project (especially important with pre-commit hooks). Is there a way of forcing it with the current code by changing any configuration?

@tummychow
Copy link
Owner

we're at the mercy of upstream for this: libgit2/libgit2#4620 and i would rather not hand-roll an implementation of hooks without upstream support

@Le09
Copy link

Le09 commented Dec 18, 2021

Hi! Thanks for the great project, git-absorb is really a fantastic help!
Whether there is CI checking the linting or not, respecting hooks is a must.
What would be the simplest workaround? I do:
git add -u; git commit -m "*"; git reset HEAD~; git add -u; git absorb --and-rebase
However it's quite cumbersome, it's worse if there's a need to do a selective add, and terrible if there's a need for a -p commit.
(the last workflow is broken in all cases by pre-commit, so -n should be added to apply the same method afterwards)

Are there simpler alternatives?

@tummychow
Copy link
Owner

honestly, i do not know of any workarounds.

@Le09
Copy link

Le09 commented Dec 21, 2021

All right, thanks for the reply :-)

@Le09
Copy link

Le09 commented Jan 18, 2022

Best wishes for the new year!
I just had another perspective about the subject. Isn't there a way to integrate pre-commit simply by running it on all modified files on the feature branch after the absorb phase?
If there are changes, you can then inspect them and rewrite as needed, and after that run absorb again.
That would reproduce the original workflow.
(if not, I guess it could also be done by creating a bash function as workaround)

@tummychow
Copy link
Owner

sorry, but like i said before, i'm not interested in hand-rolling an implementation of hooks, period. there has to be upstream support for running them the right way.

@Le09
Copy link

Le09 commented Jan 18, 2022

That's fine by me. The workaround I was thinking about is the following:

function absorbpre() {
    FS=$(git diff --cached --name-status | cut -f2 | tr '\n' ' ')
    git absorb --and-rebase 
    pre-commit run --files $FS
}

Which to me solves the problem in a satisfying way, as opposed to the previous one.

Thank you again for your work.

@tummychow tummychow added the upstream Blocked on upstream libgit2/git2rs label Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Blocked on upstream libgit2/git2rs
Projects
None yet
Development

No branches or pull requests

3 participants