Home > Mobile >  gitlab api equivalent to git log (compare branch with tag) and list commit message json
gitlab api equivalent to git log (compare branch with tag) and list commit message json

Time:03-25

i need some equivalent command to the following command:

git log --pretty="* %s%n%b" BRANCH2...TAGNAME1

i tried already the compare feature of the api but sadly without the result i expected:

curl -s --header "PRIVATE-TOKEN: XXXXXXX" "https://gitlab.localhost/api/v4/projects/3/repository/compare?from=BRANCH2&to=TAGNAME1&straight=true" | jq .

what i get is:

  "commit": null,
  "commits": [],

but git log gives me the following:

 * commit 1 description
 * commit 2 description

so what i search and need is to compare BRANCH2 with TAGNAME1 and list the different commits. this is later on needed in order to generate a changelog file which is pushed to a new tag.

CodePudding user response:

This would be the compare API

Using the gitlab-org/gitlab repo as an example, to compare the tags/branches v14.8.0-ee to v14.9.0-ee:

curl https://gitlab.com/api/v4/projects/278964/repository/compare?from=v14.8.0-ee&to=v14.9.0-ee

If you're not getting the response you're expecting, try swapping the from and to arguments and/or omitting the straight argument.

CodePudding user response:

thank you! the solution in the end was change the from and to so in the end it works like that:

curl -s --header "PRIVATE-TOKEN: XXXXXXX" "https://gitlab.localhost/api/v4/projects/3/repository/compare?from=TAGNAME1&to=BRANCH2&straight=true" | jq .

  • Related