Crocsx
Crocsx

Reputation: 7609

fatal: ambiguous argument when using git in my pipelines

I am executing the following command :

npm run affected:build:dev -- --base="$(git rev-parse origin/develop^1)"

with expected output to be the hash of the previous commit in develop ex once run

nx affected:build --configuration=develop "--base=09a1a7cf53c00a2010d907574710c71674acdf80"

this command works fine when I run on the terminal of my computer, but when running inside my bitbucket pipeline, it fails with the following error :

+ npm run affected:build:dev -- --base="$(git rev-parse origin/develop^1)"
fatal: ambiguous argument 'origin/develop^1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> [email protected] affected:build:dev
> nx affected:build --configuration=develop "--base=origin/develop^1"
fatal: Not a valid object name origin/develop^1
fatal: No such ref: 'origin/develop^1'
nx affected:build

I don't understand the cause, my pipeline is running the same versions as my local. git version 2.25.1 node v16.13.0 npm 8.1.0

what is the syntax that git is expecting ?

Upvotes: 1

Views: 512

Answers (1)

VonC
VonC

Reputation: 1324737

Just in case the '^' in develop^1 is not correctly interpreted by the shell, try instead:

git rev-parse origin/develop~1

In your case, the first parent (^1) should be the same as the first generation ancestor of the named commit object (~1).

Try also a git log origin/develop in your pipeline, just to confirm that, in the context of said pipeline execution, there is indeed a history fetched and associated with origin/develop.

Upvotes: 1

Related Questions