Build tools should check to see if they are outdated before running
Closed this issue · 3 comments
Given all the recent changes, I am a bit worried about people with outdated build tools running into problems.
If not run with --no-update, I think we should check for updates. I see a few options on how to implement this:
- Find some GitHub website or API endpoint that will tell us the latest commit hash. Pro: doesn't modify the user's local checkout at all. Con: I haven't found one in 30 seconds of searching so maybe it doesn't exist.
- Do
git fetch
then check againstorigin/master
's HEAD revision. Potential minor cons: doesn't work if you checked out the build tools with a different remote name (likewhatwg/master
instead oforigin/master
), and does modify your local git checkout, which might be unexpected.
If we find an update or any other mismatch with origin/master's HEAD I think we should warn and give instructions. (Not error, and not auto-update.)
One way we could check strictly with git
and without a git fetch
is to use git remote show …
.
Part of the last line of git remote show …
will always say either local out of date
or up to date
.
To get the info we’d need and regardless of the remote names or how many the user has, we could do:
for remote in $(git remote show | xargs); do \
echo "$remote: $(git remote show $remote | tail -n1 | xargs)"; \
done
And for the normal case if the local clone is out of date with the remote that will just report this:
origin: master pushes to master (local out of date)
And If the user has multiple remotes configured, an additional line like that for each remote.
So we could grep the output of for each local out of date
and then report to the user:
Your local clone is out of date with the "origin" remote.
Run "git pull" to bring your local up to date with the "origin" remote.
After thinking about this some more, I think we can better get what we’d need with just this:
git remote show $(git remote -v \
| grep "https://github.com/whatwg/html.git (fetch)" | cut -f1) \
| grep "pushes to master" | xargs
That’ll give just the info for the master
branch of the whatwg repo. We could then word the message as:
Your local clone is out of date with the WHATWG remote repo.
To bring your local up to date with the WHATWG remote, run this:
git checkout master && git remote pull https://github.com/whatwg/html.git master
A problem with the git remote show
approaches is that it'll just tell you the status of the master branch. If people are on a PR branch that's far behind master, it doesn't catch that.
I think that git fetch https://github.com/whatwg/html master
and some fiddling with FETCH_HEAD
should work, though.