scolladon / sfdx-git-delta

Generate the sfdx content in source format from two git commits
Other
428 stars 115 forks source link

Can't compare "HEAD~1" to "HEAD #700

Closed pirata99 closed 11 months ago

pirata99 commented 11 months ago

Hi @scolladon ,

Nice to meet you. I am using sfdx-git-delta to my DevOps Development (Salesforce-Azure Devops) but when I execute the pipeline, when commit is done, I initialize the job and i do the specific downloads (Server JWT Key, git configs, Node.js, salesforce CLI and Delta) and when I execute the command to compare different commits (current and previous):

# You can omit --to, it will take "HEAD" as default value
$ sfdx sgd:source:delta --from "HEAD~1" --output changed-sources/ --generate-delta

Then, the response is the next one:


sfdx sgd:source:delta --from "HEAD~1" --output changed-sources/ --generate-delta
========================== Starting Command Output ===========================
/usr/bin/bash /home/vsts/work/_temp/85cf0368-43e6-4def-880e-557c2bb95913.sh
(node:2029) Warning: Deprecated config name: apiVersion. Please use org-api-version instead.
(Use `node --trace-warnings ...` to show where the warning was created)
{
  "error": "fatal: Not a valid object name HEAD~1\n",
  "output": "changed-sources/",
  "success": false,
  "warnings": []
}
##[error]Bash exited with code '1'.
Finishing: Compare Commits With Delta

I suppose that the issue could be on the endline (\n) that appears in the final of the "error" attribute. But I don't know how it is produced. Can you help me to solve the issue?

Thanks a lot, Pau M

scolladon commented 11 months ago

Hi @pirata99!

Thanks for raising this issue and thanks for contributing in making this project better!

I think the issue could be because azure pipeline only download the last commit. We have a discussion explaining that here. I hope it will help

pirata99 commented 11 months ago

Hi @scolladon !

Thanks for your answer. I read the discussion explained and it makes sense that Azure does not recognize "HEAD~1" branch. Do you recommend me some solution to fix the issue? Using branches for example?

Thanks again Pau M

scolladon commented 11 months ago

I think you can still use "HEAD~1" @pirata99 But to do so you need to tell Azure pipeline to fetch those commits. The number of commits fetched is settable with the fetchDepth parameter. Here is the explanation of how to disable shallow fetching

pirata99 commented 11 months ago

Thanks @scolladon for your fast response.

By the way, I think if I set fetchDepth to 0, then I won't never get the previous commit, right? Can you confirm this?

Thanks

scolladon commented 11 months ago

I think you will Setting it to 0 makes the pipeline retrieving all the commits (according to the doc)

scolladon commented 11 months ago

@pirata99 feel free to close this issue if you found your answer

pirata99 commented 11 months ago

Hey @scolladon . I solved the issue that you mentioned about HEAD and HEAD~1. However, I am having problems to get the output of the result. I do this command:

sfdx sgd:source:delta --from "HEAD~1" --output changed-sources/ --generate-delta

I have changed-sources directory created, but no output is found there (and I did changes in different commits). Do you have some idea?

Many thanks for everything.

scolladon commented 11 months ago

Hi @pirata99, do you reproduce this issue locally? If no, could you give us the azure pipeline definition you are using please? I think there is something with how commits are fetched with azure pipeline and I suspect only the current commit is checked out even if everything is fetched.

scolladon commented 11 months ago

Hi @pirata99

Have you been able to find a resolve this? Let us know so we can either help you or close this issue