scolladon / sfdx-git-delta

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

Plugin saying it can't find branches - '--to is not a valid sha pointer: \"HEAD\"' #302

Closed peter-caitens closed 2 years ago

peter-caitens commented 2 years ago

Issue verification check:

What is the problem?

I have begun to see the following error in my Github pipeline:

{
  "error":  --to is not a valid sha pointer: \"HEAD\", --from is not a valid sha pointer: \"origin/main\"",
  "output": "deployFolder",
  "success": false,
  "warnings": []
}

I am running this on my own docker image in a Github pipeline. It was recently updated and the Git version was updated from 2.32.0 to 2.34.2. Everything was working fine and now my pipeline is broken as I rely on this plugin.

What is the parameter and the value you used with it?

export HOME=/root && sfdx sgd:source:delta --from origin/main --to HEAD --output deployFolder --generate-delta --source force-app

What is the expected result?

I would expect that the deployfolder is populated with the output from the command like it used to.

Operating System: node:14-alpine docker image yarn version: v1.22.17 node version: 14 git version: 2.34.2 sfdx version: sfdx-cli/7.149.1 linux-x64 node-v14.19.1 sfdx plugins --core versions @oclif/plugin-autocomplete 0.3.0 (core) @oclif/plugin-commands 1.3.0 (core) @oclif/plugin-help 3.3.1 (core) @oclif/plugin-not-found 1.2.6 (core) @oclif/plugin-plugins 1.10.11 (core) @oclif/plugin-update 1.5.0 (core) @oclif/plugin-warn-if-update-available 1.7.3 (core) @oclif/plugin-which 1.0.4 (core) @salesforce/sfdx-plugin-lwc-test 0.1.7 (core) alias 2.0.0 (core) apex 0.11.0 (core) auth 2.0.2 (core) community 1.1.4 (core) config 1.3.30 (core) custom-metadata 1.1.0 (core) data 0.6.15 (core) generator 1.2.2 (core) info 2.0.0 (core) limits 2.0.0 (core) org 1.12.1 (core) salesforce-alm 54.2.1 (core) schema 2.1.0 (core) sfdx-cli 7.149.1 (core) source 1.9.6 (core) telemetry 1.4.0 (core) templates 54.5.0 (core) trust 1.1.0 (core) user 1.7.1 (core)

sgd plugin version: Says no plugins installed however it was installed with

RUN npm install --global sfdx-cli@latest
RUN echo 'y' | sfdx plugins:install sfdx-git-delta

Provide the output of these commands:

$ git diff --name-status --no-renames origin/main HEAD error: Could not access 'origin/main'

After retrieving main locally $ git diff --name-status --no-renames main HEAD M .github/actions/sfdx-deploy-changes/action.yml M .github/workflows/deploy.yml M .github/workflows/nightly-dev-pipeline.yml A .github/workflows/sync-to-upstream-branches.yml M CHANGELOG.md M README.md M build-settings/Template-NextRelease-CHANGELOG.md M build-settings/scripts/current-release-post.apex M build-settings/scripts/current-release-pre.apex A force-app/main/applications/AMPApp.app-meta.xml M force-app/main/classes/NanoApplication.cls M force-app/main/classes/VertevaUtils.cls A force-app/main/classes/domains/Valuations.cls A force-app/main/classes/domains/Valuations.cls-meta.xml A force-app/main/classes/tests/ApplicationLoanBeforeUpdateTest.cls A force-app/main/classes/tests/ApplicationLoanBeforeUpdateTest.cls-meta.xml A force-app/main/classes/tests/ValuationTriggerTest.cls A force-app/main/classes/tests/ValuationTriggerTest.cls-meta.xml M force-app/main/classes/tests/VertevaUtilsTest.cls A force-app/main/customPermissions/AppActionButtons.customPermission-meta.xml A force-app/main/customPermissions/AppDecision.customPermission-meta.xml A force-app/main/customPermissions/AppSettlement.customPermission-meta.xml A force-app/main/customPermissions/AppValuation.customPermission-meta.xml M force-app/main/flexipages/Application_MAPS.flexipage-meta.xml A force-app/main/flexipages/Application_Partner.flexipage-meta.xml M force-app/main/flows/Application_Loan_Before_Update.flow-meta.xml M force-app/main/flows/Case_before_Save_Set_Partner.flow-meta.xml A force-app/main/groups/AMPDataGroup.group-meta.xml A force-app/main/groups/AMPGroup.group-meta.xml A force-app/main/groups/AMPSupportGroup.group-meta.xml A force-app/main/groups/ConnectiveDataGroup.group-meta.xml A force-app/main/groups/ConnectiveGroup.group-meta.xml A force-app/main/groups/NanoDataGroup.group-meta.xml A force-app/main/groups/NanoGroup.group-meta.xml M force-app/main/layouts/Applicationc-Application Layout.layout-meta.xml M force-app/main/layouts/Assetc-Application Asset Layout.layout-meta.xml M force-app/main/layouts/Partnerc-Partner Layout.layout-meta.xml M force-app/main/layouts/Propertyc-Property Layout.layout-meta.xml M force-app/main/objects/Account/fields/PartnerNamec.field-meta.xml M force-app/main/objects/Applicantc/fields/ConsentBureauc.field-meta.xml M force-app/main/objects/Applicantc/fields/Consentc.field-meta.xml M force-app/main/objects/ApplicationLoanc/fields/SourceOfFundsc.field-meta.xml M force-app/main/objects/Applicationc/fields/PartnerNamec.field-meta.xml A force-app/main/objects/Applicationc/fields/SettlementInstructionsc.field-meta.xml A force-app/main/objects/Applicationc/fields/Usefundsfrompropertysalec.field-meta.xml M force-app/main/objects/Assetc/fieldSets/financials.fieldSet-meta.xml M force-app/main/objects/Assetc/fields/Classc.field-meta.xml A force-app/main/objects/Assetc/fields/IsFutureAssetc.field-meta.xml A force-app/main/objects/Assetc/fields/OtherClassTextc.field-meta.xml A force-app/main/objects/Assetc/fields/PropertySaleAddressc.field-meta.xml A force-app/main/objects/Assetc/fields/PropertySaleCompletec.field-meta.xml A force-app/main/objects/Assetc/fields/PropertySaleLoanAmountc.field-meta.xml A force-app/main/objects/Assetc/fields/SourceOfFundsc.field-meta.xml M force-app/main/objects/Campaign/fields/PartnerNamec.field-meta.xml M force-app/main/objects/Case/fields/PartnerNamec.field-meta.xml M force-app/main/objects/Lead/fields/PartnerNamec.field-meta.xml A force-app/main/objects/Propertyc/fields/AdditionalInformationc.field-meta.xml A force-app/main/objects/Propertyc/fields/IssueDatec.field-meta.xml A force-app/main/objects/Propertyc/fields/LandDescriptionc.field-meta.xml A force-app/main/objects/Propertyc/fields/OrderIDc.field-meta.xml A force-app/main/objects/Propertyc/fields/RegisteredOwnerOwnerSharec.field-meta.xml A force-app/main/objects/Propertyc/fields/SearchDateTimec.field-meta.xml A force-app/main/objects/Propertyc/fields/SecurityStatusc.field-meta.xml A force-app/main/objects/Propertyc/fields/TitleReference__c.field-meta.xml M force-app/main/permissionsetgroups/Partner_ReadOnly.permissionsetgroup-meta.xml M force-app/main/permissionsetgroups/Partner_Settlement.permissionsetgroup-meta.xml M force-app/main/permissionsetgroups/Partner_Underwriter.permissionsetgroup-meta.xml A force-app/main/permissionsets/AMPApp.permissionset-meta.xml M force-app/main/permissionsets/ApplicantDetails_EDIT.permissionset-meta.xml M force-app/main/permissionsets/ApplicantDetails_RO.permissionset-meta.xml M force-app/main/permissionsets/ApplicationDetails_EDIT.permissionset-meta.xml M force-app/main/permissionsets/ApplicationDetails_RO.permissionset-meta.xml M force-app/main/permissionsets/Financials_CRUD.permissionset-meta.xml M force-app/main/permissionsets/Financials_RO.permissionset-meta.xml M force-app/main/permissionsets/PropertyAndValuation_EDIT.permissionset-meta.xml M force-app/main/permissionsets/PropertyAndValuation_RO.permissionset-meta.xml A force-app/main/triggers/ValuationTrigger.trigger A force-app/main/triggers/ValuationTrigger.trigger-meta.xml M sonar-project.properties

mehdicherf commented 2 years ago

Hi @peter-caitens. Thank for taking the time to log your issue with all the details.

You shared that when running git diff --name-status --no-renames origin/main HEAD it returned the following error: error: Could not access 'origin/main'

This is likely the explanation why SGD returns an error when trying to use origin/main.

I'm not sure why you can't access origin/main from your pipeline (for example, this error could occur when the command is not executed from a git repo), but you need to fix that error first. You will be able to use SGD on that branch only once the git diff --name-status --no-renames origin/main HEAD returns the expected result.

peter-caitens commented 2 years ago

It is being executed from a git repo. I ran the following commands and it did return the correct list of changes on the repo.

get fetch
git checkout main origin/main
git checkout staging
git diff --name-status --no-renames main HEAD

This was the general way I had been using it for a while until it stopped working. I only tried it using origin/main while trying various things to see I could fix it.

Something has changed and I am trying to determine what. What software does the plugin require for it to run?

peter-caitens commented 2 years ago

Hi @mehdisfdc, after getting your reply I found your docker file at https://hub.docker.com/r/mehdisfdc/sfdx-cli-gitlab/dockerfile I used it and all is working again. I must have had the wrong version of something in my image. Thanks

mehdicherf commented 2 years ago

@peter-caitens Ok thank you for the clarification.

The docker image https://hub.docker.com/r/mehdisfdc/sfdx-cli-gitlab/dockerfile has not been updated recently. ⚠️ I'll soon (probably today) upgrade it with the latest versions of the Salesforce CLI and SGD: please let us know if you see any issue on your end as a result of this upgrade (because it would mean that you found a bug in SGD).

(NOTE: if it turns to be a bug in SGD's current version, as a workaround you can specify an older version when installing the plugin, so that you can use it in your pipeline while we investigate the issue: sfdx plugins:install sfdx-git-delta@4.12.1)

peter-caitens commented 2 years ago

I have taken your Dockerfile and added a few bash commands that I needed and ran it as my own image and it works fine for me. Thanks.

mehdicherf commented 2 years ago

Glad to read that, thank you for the update @peter-caitens!