13rac1 / block-fixup-merge-action Goto Github PK
View Code? Open in Web Editor NEWGithub Action to block merge of Pull Requests containing fixup! or squash! commits
License: MIT License
Github Action to block merge of Pull Requests containing fixup! or squash! commits
License: MIT License
There is a new beta feature in GitHub called merge queues: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue
This action could be used in there, just like with Pull requests, but it's not compatible
shellcheck raises a few minor issues -- thoughts about #27 ?
$> shellcheck --format gcc entrypoint.sh
entrypoint.sh:21:15: note: Use $(...) notation instead of legacy backticks ...
. [SC2006]
entrypoint.sh:23:15: note: Use $(...) notation instead of legacy backticks ...
. [SC2006]
entrypoint.sh:23:21: note: Double quote to prevent globbing and word splitting. [SC2086]
entrypoint.sh:23:36: note: Consider using grep -c instead of grep|wc -l. [SC2126]
entrypoint.sh:31:16: note: Use $(...) notation instead of legacy backticks ...
. [SC2006]
entrypoint.sh:31:22: note: Double quote to prevent globbing and word splitting. [SC2086]
entrypoint.sh:31:37: note: Consider using grep -c instead of grep|wc -l. [SC2126]
Hey
Great action!
Is it suppose to work with private repositories?
so far I've been getting:
fatal: couldn't find remote ref xx/merge
** xx marks the pr number of course.
The script only compares current branch with master right now. It could check for closest branch https://stackoverflow.com/questions/3161204/how-to-find-the-nearest-parent-of-a-git-branch but that isn't always correct.
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
The best way is probably using the Github API https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit
GET /repos/:owner/:repo/commits/:commit_sha/pulls
These are similar to --fixup commits, but aren't mentioned in your docs. Could these be blocked too?
Hand in hand with fixup!
commits are !amend
commits (e.g. git commit --fixup=amend:<SHA>
)
Would be great if this action also blocked on those
๐ค Oddly this stopped working. There was a change to the Github Actions git configuration which made the git history disappear. Two issues:
Current ref: refs/heads/test-action
Current branch: test-action
fatal: ambiguous argument 'origin/master..origin/test-action': unknown revision or path not in the working tree.
Fixup! commits: 0
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Hi @13rac1,
If you're using this action to be a required check of a pull request, how can it ever succeed if it fails after the first push? The history of the failed Github actions remains in the checks-list, so it will always have an unsuccessful check, blocking the merge, if you fix the issues in a push following a failed one.
Example output:
Current ref: refs/pull/790/merge
(snip)
Current branch: 90/merge
I believe the error is on this line:
My build is getting deprecation warnings with this action:
--
The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/Show less
When looking at the entrypoint.sh
source, I noticed refspecs containing __ci_base
and __ci_pr
(https://github.com/13rac1/block-fixup-merge-action/blob/master/entrypoint.sh#L26), but I cannot find any documentation on these tags (I assume they're tags). I'm noticing issues where the git log __ci_base..__ci_pr
command is returning a list of commits farther back than the base ref.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.