Unverified Commit 0ffe6f9c authored by Tingluo Huang's avatar Tingluo Huang Committed by GitHub
Browse files

Add set-safe-directory input to allow customers to take control. (#770)

* Add set-safe-directory input to allow customers to take control.
parent dcd71f64
Loading
Loading
Loading
Loading
+38
Changes for .github/workflows/test.yml: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -205,3 +205,41 @@ jobs:
          path: basic
      - name: Verify basic
        run: __test__/verify-basic.sh --archive
    
  test-git-container:
    runs-on: ubuntu-latest
    container: bitnami/git:latest
    steps:
      # Clone this repo
      - name: Checkout
        uses: actions/checkout@v3
        with:
          path: v3

      # Basic checkout using git
      - name: Checkout basic
        uses: ./v3
        with:
          ref: test-data/v2/basic
      - name: Verify basic
        run: |
          if [ ! -f "./basic-file.txt" ]; then
              echo "Expected basic file does not exist"
              exit 1
          fi

          # Verify .git folder
          if [ ! -d "./.git" ]; then
            echo "Expected ./.git folder to exist"
            exit 1
          fi

          # Verify auth token
          git config --global --add safe.directory "*"
          git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main

      # needed to make checkout post cleanup succeed
      - name: Fix Checkout v3
        uses: actions/checkout@v3
        with:
          path: v3
 No newline at end of file
+5
Changes for README.md: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
    #
    # Default: false
    submodules: ''

    # Add repository path as safe.directory for Git global config by running `git
    # config --global --add safe.directory <path>`
    # Default: true
    set-safe-directory: ''
```
<!-- end usage -->

+2 −1
Changes for __test__/git-auth-helper.test.ts: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -777,7 +777,8 @@ async function setup(testName: string): Promise<void> {
    sshKey: sshPath ? 'some ssh private key' : '',
    sshKnownHosts: '',
    sshStrict: true,
    workflowOrganizationId: 123456
    workflowOrganizationId: 123456,
    setSafeDirectory: true
  }
}

+1
Changes for __test__/input-helper.test.ts: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ describe('input-helper tests', () => {
    expect(settings.repositoryName).toBe('some-repo')
    expect(settings.repositoryOwner).toBe('some-owner')
    expect(settings.repositoryPath).toBe(gitHubWorkspace)
    expect(settings.setSafeDirectory).toBe(true)
  })

  it('qualifies ref', async () => {
+3
Changes for action.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ inputs:
      When the `ssh-key` input is not provided, SSH URLs beginning with `[email protected]:` are
      converted to HTTPS.
    default: false
  set-safe-directory:
    description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
    default: true
runs:
  using: node16
  main: dist/index.js
Loading