prepush runs all on setting upstream #394
Replies: 4 comments
-
Hey! Try passing the files to the pre-push:
commands:
a:
root: "libs/a/"
files: git diff --name-only HEAD @{push}
run: npm run test {files}
b:
root: "libs/b/"
files: git diff --name-only HEAD @{push}
run: npm run test {files} |
Beta Was this translation helpful? Give feedback.
-
hey!
|
Beta Was this translation helpful? Give feedback.
-
Ok, so I came up with such inline bash if no upstream branch get diff from branch to be pushed head and main branch (origin/HEAD) a:
root: "lib/any/"
files: if [[ $(git name-rev @{u}) ]]; then return $(git diff --name-only HEAD @{push}); else return $(git diff --name-only origin/HEAD HEAD); fi
run: npm test but it isn't working and seems not running
a:
root: "lib/any/"
files: ./scripts/get-filenames-on-push.sh
run: npm test As I got lefthook docs you can only provide scripts to |
Beta Was this translation helpful? Give feedback.
-
Hey!
What if you try this pre-push:
commands:
a:
root: "lib/a/"
files: git diff-tree -r --name-only --diff-filter=CDMR HEAD origin/master # the changed files
run: npm test {files} # this is important, otherwise it will just run tests without arguments |
Beta Was this translation helpful? Give feedback.
-
I will not say that the problem is with Lefthook.
But the examples you can find in the documentation are just that.
I would like to ask for advice or a solution to this situation.
Suppose we have a mono repository.
We have set up something like this
The problem is that when I create a new branch and make changes only for
a
and push it, all the tests run.In subsequent pushes, this behavior is not observed.
Perhaps there is a more robust way to get the names of the changed files then
git diff --name-only HEAD @{push}
, taking into accountroot
.Beta Was this translation helpful? Give feedback.
All reactions