Skip to content

[Feature Request] Add commit being operated on as an arg to 'git test' #1346

Answered by claytonrcarter
mfulbright asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there. It looks like this may already be supported via the $BRANCHLESS_TEST_COMMIT env var. (I didn't see that mentioned in the wiki docs, but it looks like it's being injected in the code: https://github.com/arxanas/git-branchless/blob/master/git-branchless-test/src/lib.rs#L2645) Can you try this and see if it works for you:

# Fail any commits that still have "TODO_BEFORE_SUBMIT" in their changes:
$ git test run --exec '[[ ! $(git diff "$BRANCHLESS_TEST_COMMIT"^ "$BRANCHLESS_TEST_COMMIT" | grep TODO_BEFORE_SUBMIT) ]]'

Although in this case, I wonder if you could bypass the env var entirely and just do git diff @^ to get the diff for the current commit and its parent.

Fair warning: I …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@arxanas
Comment options

@mfulbright
Comment options

Answer selected by arxanas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1337 on June 15, 2024 22:29.