I need a git diff of the files that have changed between my feature branch and develop. The list of changed files is fed into the rubocop linter to check for violations being pushed out with this branch.
When I run the following command locally, it returns a list of the changed files between HEAD and my develop branch:
git diff develop HEAD --name-only | egrep '.+/.+.rb'
When I run this on CircleCI (either as part of a job, or via SSH), the git-diff command returns no content.
Can anyone offer any insight into what I’m doing wrong?
This is correct. Git in your CircleCI container is not the same as Git on your local machine. By default, git is not configured inside of your container.
One approach you might use is to compare your feature and develop branch within your container. Please feel free to share your config.yml file if you’s like me to chime in on a more detailed solution.
I have the same error. I was using the git-diff job in Travis Ci but I removed it from Travis Ci and tried to execute it in CircleCI but it doesn’t provide any content.
With the example config file you have provided you are making use of the -checkout command within the circleci scripting language and have told it to operate within a newly created docker instance. The result is that you will end up with just the head of the branch that was modified/tagged to cause the CI job to start.
The result is that you do not have a current and past instance of your repo locally to do a diff against.
From the web GUI you can see the detail of the -checkout step which is just a shell script that executes git based on the type of build (branch or tag) and the target environment (dynamic or static instance). You may need to use your own script as a replacement if you wish to be able to generate a diff report and/or use the persisting data features.