Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sparse-checkout git command line behavior #7634

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

danieljurek
Copy link
Member

@danieljurek danieljurek commented Feb 5, 2024

This is found in pipelines which were using the Azure Pipelines pool (not 1ES) and invoked sparse-checkout.yml in this way:

https://github.com/Azure/azure-sdk-for-java/blob/main/eng/pipelines/docindex.yml#L19-L29

      - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
        parameters:
          SkipCheckoutNone: true
          Paths:
            - package.json
            - metadata/
            - docs-ref-mapping/reference-unified.yml
            - docs-ref-services/
          Repositories:
            - Name: $(DocRepoOwner)/$(DocRepoName)
              WorkingDirectory: $(DocRepoLocation)

The final command in the sparse checkout fails:

git -c advice.detachedHead=false checkout $commitish --

When checking on parameter binding a subtle difference occurs:

$PSNativeCommandArgumentPassing = 'Windows' 
Trace-Command -PSHost -Expression { git -c advice.detachedHead=false checkout $commitish -- } -Name ParameterBinding
DEBUG: 2024-02-05 09:36:16.2451 ParameterBinding Information: 0 : BIND NAMED native application line args [C:\Program Files\Git\cmd\git.exe]
DEBUG: 2024-02-05 09:36:16.2454 ParameterBinding Information: 0 :     BIND cmd line arg [-c] to position [0]
DEBUG: 2024-02-05 09:36:16.2456 ParameterBinding Information: 0 :     BIND cmd line arg [advice.detachedHead=false] to position [1]
DEBUG: 2024-02-05 09:36:16.2458 ParameterBinding Information: 0 :     BIND cmd line arg [checkout] to position [2]
DEBUG: 2024-02-05 09:36:16.2460 ParameterBinding Information: 0 :     BIND cmd line arg [] to position [3]
DEBUG: 2024-02-05 09:36:16.2462 ParameterBinding Information: 0 :     BIND cmd line arg [--] to position [4]
DEBUG: 2024-02-05 09:36:16.2499 ParameterBinding Information: 0 : CALLING BeginProcessing

$PSNativeCommandArgumentPassing = 'Windows'  
Trace-Command -PSHost -Expression { & git "-c advice.detachedHead=false checkout $commitish --" } -Name ParameterBinding
DEBUG: 2024-02-05 09:14:00.4704 ParameterBinding Information: 0 : BIND NAMED native application line args [C:\Program Files\Git\cmd\git.exe]
DEBUG: 2024-02-05 09:14:00.4707 ParameterBinding Information: 0 :     BIND cmd line arg [-c advice.detachedHead=false checkout  --] to position [0]
DEBUG: 2024-02-05 09:14:00.4743 ParameterBinding Information: 0 : CALLING BeginProcessing

$PSNativeCommandArgumentPassing = 'Legacy' 
Trace-Command -PSHost -Expression {  git -c advice.detachedHead=false checkout $commitish -- } -Name ParameterBinding
DEBUG: 2024-02-05 09:12:55.4343 ParameterBinding Information: 0 : BIND NAMED native application line args [C:\Program Files\Git\cmd\git.exe]
DEBUG: 2024-02-05 09:12:55.4347 ParameterBinding Information: 0 :     BIND argument [-c advice.detachedHead=false checkout  --]
DEBUG: 2024-02-05 09:12:55.4386 ParameterBinding Information: 0 : CALLING BeginProcessing

Note the BIND cmd line arg in the Windows configuration versus BIND argument in the Legacy configuration.

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@weshaggard
Copy link
Member

@danieljurek can you point to a failing pipeline? I'm not sure I'm following what the issue is here. I would expect this to work as is unless I'm missing something from my understanding in the command parsing. Do we not want it parse these out individually?

@danieljurek
Copy link
Member Author

Example job running a (previously valid) invocation of sparse-checkout.yml and failing: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3465292&view=logs&j=dc056dfc-c0cf-5958-c8c4-8da4f91a3739&t=7c454773-5fe4-5b1a-32e8-1930d4be8312 (note the fact that it's running in Azure Pipelines as opposed to 1ES pipelines)

Example job running invocation of sparse-checkout.yml and succeeding: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3465356&view=logs&j=dc056dfc-c0cf-5958-c8c4-8da4f91a3739&t=fd8e7423-8fbc-52ed-a0aa-20018c9cc442 (this is running in a 1ES pipeline)

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@danieljurek
Copy link
Member Author

azure-sdk added a commit to Azure/azure-sdk-for-js that referenced this pull request Feb 6, 2024
@danieljurek danieljurek merged commit b2d2c4d into main Feb 6, 2024
7 checks passed
@danieljurek danieljurek deleted the djurek/sparse-checkout-pwsh74 branch February 6, 2024 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants