Travis CI example config runs git pull into branch
tomekr opened this issue · comments
It looks like with the way Travis CI works, if you git pull origin master:master
, it tries to pull in masters changes into the checked out branch causing it to fail. Example build:
https://travis-ci.com/github/tomekr/jamroulette/jobs/302690415
Switching it to git fetch origin master:master
fixed the issue for me.
Hi! Thanks you for using undercover and reporting this.
We use git pull
in this github action and it works fine: master:master
ref explicitly asks for an update of master
and not HEAD
. Can you double check if it works with your project to exclude any other possible causes?
Hmm, if you follow the command Travis CI runs in the build, it looks like this isn't an ideal state for the repo to be in before undercover runs?
(base) ➜ ~ git clone --depth=50 --branch=ui-notifications https://github.com/tomekr/jamroulette.git
Cloning into 'jamroulette'...
remote: Enumerating objects: 783, done.
remote: Counting objects: 100% (783/783), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 783 (delta 390), reused 693 (delta 329), pack-reused 0
Receiving objects: 100% (783/783), 361.10 KiB | 3.44 MiB/s, done.
Resolving deltas: 100% (390/390), done.
(base) ➜ ~ cd jamroulette
(base) ➜ jamroulette git:(ui-notifications) git status
On branch ui-notifications
Your branch is up to date with 'origin/ui-notifications'.
nothing to commit, working tree clean
(base) ➜ jamroulette git:(ui-notifications) git pull origin master:master
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 16 (delta 10), reused 10 (delta 6), pack-reused 0
Unpacking objects: 100% (16/16), done.
From https://github.com/tomekr/jamroulette
* [new branch] master -> master
Auto-merging db/schema.rb
CONFLICT (content): Merge conflict in db/schema.rb
Automatic merge failed; fix conflicts and then commit the result.
(base) ➜ jamroulette git:(ui-notifications) ✗ gs
On branch ui-notifications
Your branch is up to date with 'origin/ui-notifications'.
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
modified: Gemfile
modified: Gemfile.lock
modified: README.md
new file: bin/delayed_job
modified: config/environments/production.rb
new file: db/migrate/20200402223118_create_delayed_jobs.rb
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: db/schema.rb
Maybe i'm misunderstanding how undercover works, but if git pull origin master:master
pulls master code into your existing branch and then runs undercover, i'd expect it would always pass since masters code is now in the branch code (until there is some merge conflict that prevents all the code from being merged in)
git fetch origin master:master
accomplishes the same thing without the attempted git merge.
Thanks for sharing that build log. Turns out I missed that pull master:master
will do two things: update master and the current branch too, which kind of makes sense (https://stackoverflow.com/a/42902058). Undercover performs just the diff
command to compare refs, so there's no need to merge in master every time.
it would always pass since masters code is now in the branch code
This, however, is not true for most cases, because the branch would still have unmerged changes ahead of master.
I am soon going to change the build config here as well as docs to suggest using fetch
or, if you feel like it, please open a PR!