For this repro repo
in a CircleCI pipeline build job
git rev-list --count develop..$CIRCLE_SHA1
returns 0.
Ditto for
git rev-list --count develop..HEAD
.
Also git rev-list develop..HEAD
does nothing.
All the git commands above produce a different result when run locally.
git rev-list --count HEAD
returns the same non zero value for both local and CircleCI runs.It appears git rev-list fails on CircleCI whenever a gitrevision range argument is supplied
Am I doing something wrong? How do I get
git rev-list
to work with a gitrevision range?
config.yml
version: 2.1
executors:
base:
docker:
- image: cimg/base:2020.01
jobs:
build:
executor: base
steps:
- checkout
- run:
name: Test git in bash script
command: chmod +x .circleci/circle_test.sh && .circleci/circle_test.sh
- run:
name: Test git in circleci command
environment:
PACKAGE_PATH: "./packages"
command: |
echo -e $(git rev-list -1 develop..$CIRCLE_SHA1 -- ${PACKAGE_PATH#./} | cat)
echo -e $(git rev-list -1 develop..$CIRCLE_SHA1 | cat)
echo -e $(git rev-list develop..$CIRCLE_SHA1 | cat)
git rev-list --count develop..$CIRCLE_SHA1
git rev-list --count HEAD
workflows:
version: 2
ci:
jobs:
- build
.circleci/circle_test.sh
PACKAGE_PATH="./packages"
LATEST_PACKAGE_COMMIT_SINCE_DEVELOP=$(git rev-list -1 develop..$CIRCLE_SHA1 -- ${PACKAGE_PATH#./})
LATEST_COMMIT_SINCE_DEVELOP=$(git rev-list -1 develop..$CIRCLE_SHA1)
COMMITS_SINCE_DEVELOP=$(git rev-list develop..$CIRCLE_SHA1)
COMMITS_COUNT_SINCE_DEVELOP=$(git rev-list --count develop..$CIRCLE_SHA1)
COMMITS_COUNT=$(git rev-list --count HEAD)
echo -e "\e[36m first changed commit in package since develop $LATEST_PACKAGE_COMMIT_SINCE_DEVELOP \e[0m"
echo -e "\e[36m first changed commit since develop $LATEST_COMMIT_SINCE_DEVELOP \e[0m"
echo -e "\e[36m commits since develop $COMMITS_SINCE_DEVELOP \e[0m"
echo -e "\e[36m commits count since develop $COMMITS_COUNT_SINCE_DEVELOP \e[0m"
echo -e "\e[36m commits count $COMMITS_COUNT \e[0m"
echo -e "\e[36m this commit $CIRCLE_SHA1 \e[0m"