pronto
pronto copied to clipboard
No commit option in .pronto.yml? (also, crashes unless local master exists)
(Didn't see this brought up elsewhere. And from what I can tell, behavior is the same in master as my installed version of 0.7.1.)
Essentially, I think it'd be useful if you could set pronto to check against origin/master
rather than master
. There are a couple of reasons for this:
- not all workflows require having a local master branch (e.g. even for small changes, we make a feature branch, push it upstream, and create a PR)
- when working on a feature, it's easy to not be aware that
master
is out of date withorigin/master
, and if you run pronto after mergingorigin/master
into your feature branch, you'll end up with spurious results since the diff will include recent merges as well as your own code.
Obviously, this is fixed by always passing -c origin/master
to pronto. But I think it'd be convenient if this could be configured in .pronto.yml. (Sorry if that already exists -- I looked at the docs and code but didn't see a way to configure the default commit, and tried adding commit:
to .pronto.yml to no effect.
Also, Pronto crashes when it can't find the commit it's looking for with
...pronto-0.7.1/lib/pronto/git/repository.rb:72:in `merge_base': Revspec 'foo/bar' not found. (Rugged::ReferenceError)
Of course, there's no way to recover from this error, but it might be nice to show a friendlier error message. For instance, fat-fingering the argument to -c
will trigger this, and I wouldn't consider that to be "exceptional," really.
I'm willing to make PRs for these changes if they're in fact desired.
I'm willing to make PRs for these changes if they're in fact desired.
@johncip yes, go for it! 😄 Sorry for a late reply 🙇.
Please post an update if you intend to do it, so we wouldn't end up in a situation where we both are doing the same work 😄.
Ok!
@mmozuras thanks for the useful gem.
Pronto version 0.11.0
does not handle PRONTO_DEFAULT_COMMIT
.
Do you plan on releasing a new version that supports it?
That would be super useful for those of us whose default/base branch is main
instead of master
and when pronto
is not installed via bundler
.
In the meantime, below is an example of a workaround I use to get the commit in .git/hooks/pre-push
.
This git hook asks pronto to run Rubocop (thanks to pronto-rubocop
) before pushing to the remote repository.
Note the last line retrieves the name of the base branch git name-rev --name-only HEAD
:
pronto run -c $(git name-rev --name-only HEAD) --exit-code
My understanding is that HEAD
denotes the main/base branch checked out by default when cloning the repository. It is most often main
in recent repositories or master
in older ones. Then, in the local repository HEAD
is a symbolic ref to the base branch.
The actual value of HEAD
of course is configured in the repository, for instance in Github:
https://github.com/USERNAME/REPO/settings/branches.
#!/bin/sh
# To reinstall this script in the same or another git repo run:
# curl -sSL https://gist.githubusercontent.com/elliotthilaire/cef91754bb296d67e776/raw/pre-push > .git/hooks/pre-push; chmod +x .git/hooks/pre-push
# check that pronto is installed
# Source: http://elliotthilaire.net/gem-pronto-and-git-hooks/
#
hash pronto 2>/dev/null || {
echo >&2 "Pronto is not installed. Install with 'gem install pronto pronto-rubocop'";
echo >&2 "Find other Pronto runners at https://github.com/mmozuras/pronto#runners";
exit 0;
}
# Run pronto
pronto run -c $(git name-rev --name-only HEAD) --exit-code