labs42io / circleci-monorepo

An example of monorepo with CircleCI using conditional workflows and pipeline parameters.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

monorepo.sh does not detect any change when merging branch A to branch B with MergeCommit

mdanish0320 opened this issue · comments

let say we have 2 branches development and master. we have checkout to branch development and make changes and push code. All is good here.
Now we want to merge our development branch to master branch, suppose that we added multiple features in development branch so we want to keep commit history.

When we merge development to master using

  • squash, this work fine
  • merge commit, here our monorepo.sh does not find any changes

The logs are

No config file found at /home/circleci/project/.circleci/monorepo.json. Using defaults.
Getting workflow status:
	GET: [200] https://circleci.com/api/v1.1/project/github/<user>/<repo>/tree/master?shallow=true&limit=100&offset=0
Created build-commit map /home/circleci/project/.circleci/temp/builds.json
First built commit in branch: 5fbce9392a203768006daa39617cf1a75bb37682
	Could not find parent commit relative to first build commit.
	Either branch was force pushed or build commit too old.
Parent commit: 8162e15

for a quick fix. I've replaced 1 line of code.
parent_commit=$(get_parent_commit null)
changed above to below
parent_commit=$(git cat-file -p ${CIRCLE_SHA1} | grep 'parent' | head -1 | awk '{print $2}')

I guess this happened because it was the first CI build into your master branch. It should work fine for all subsequent merges and commits without changing the code in monorepo.sh.