Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hashicorp/go-getter
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.2
Choose a base ref
...
head repository: hashicorp/go-getter
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.7.3
Choose a head ref
  • 8 commits
  • 4 files changed
  • 3 contributors

Commits on Apr 21, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    dbb4c7a View commit details

Commits on Sep 8, 2023

  1. Merge pull request #432 from hashicorp/tsccr-auto-pinning/trusted/202…

    …3-04-21
    
    SEC-090: Automated trusted workflow pinning (2023-04-21)
    NodyHub authored Sep 8, 2023
    Copy the full SHA
    2d49e24 View commit details

Commits on Sep 11, 2023

  1. Copy the full SHA
    e80b3dc View commit details
  2. Merge pull request #454 from hashicorp/tsccr-auto-pinning/trusted/202…

    …3-09-11
    
    SEC-090: Automated trusted workflow pinning (2023-09-11)
    NodyHub authored Sep 11, 2023
    Copy the full SHA
    e66f244 View commit details

Commits on Sep 18, 2023

  1. Copy the full SHA
    0688979 View commit details
  2. Merge pull request #458 from hashicorp/tsccr-auto-pinning/trusted/202…

    …3-09-18
    
    SEC-090: Automated trusted workflow pinning (2023-09-18)
    NodyHub authored Sep 18, 2023
    Copy the full SHA
    3d5770f View commit details

Commits on Oct 9, 2023

  1. don't change GIT_SSH_COMMAND if there's no keyfile

    The reason for setupGitEnv is to add a `-i keyfile` argument to
    GIT_SSH_COMMAND. If there is no keyfile, we do not need to modify the
    environment at all.
    jbardin committed Oct 9, 2023
    Copy the full SHA
    c70d9c9 View commit details

Commits on Oct 10, 2023

  1. Merge pull request #459 from hashicorp/jbardin/setup-git-env

    don't change GIT_SSH_COMMAND when there is no sshKeyFile
    jbardin authored Oct 10, 2023
    Copy the full SHA
    0298a22 View commit details
Showing with 48 additions and 22 deletions.
  1. +12 −12 .github/workflows/go-getter.yml
  2. +3 −3 .github/workflows/release.yml
  3. +10 −7 get_git.go
  4. +23 −0 get_git_test.go
24 changes: 12 additions & 12 deletions .github/workflows/go-getter.yml
Original file line number Diff line number Diff line change
@@ -20,19 +20,19 @@ jobs:
contents: read
steps:
- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}
- name: Setup cache for go modules
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.cache/go-build
@@ -59,15 +59,15 @@ jobs:
run: go install gotest.tools/gotestsum@v1.8.2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp

- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0.4.0'
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
@@ -82,7 +82,7 @@ jobs:
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: linux test results
path: linux_cov.part
@@ -103,15 +103,15 @@ jobs:
run: git config --global core.autocrlf false

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Setup cache for go modules
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~\AppData\Local\go-build
@@ -128,15 +128,15 @@ jobs:
run: go install gotest.tools/gotestsum@v1.8.2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp

- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0.4.0'
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
@@ -152,7 +152,7 @@ jobs:
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: windows test results
path: win_cov.part
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v2
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '^1.15'
- name: Setup signore
@@ -46,7 +46,7 @@ jobs:
VERSION: 1.6.4
SHA256SUM: 3ad66eebd443d32dd6c811dcf2d264b78678c75ed1d40c15434180d4453e60d2
- name: GitHub Release
uses: goreleaser/goreleaser-action@v1
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
version: latest
args: release --skip-validate --timeout "60m"
17 changes: 10 additions & 7 deletions get_git.go
Original file line number Diff line number Diff line change
@@ -302,6 +302,11 @@ func findRemoteDefaultBranch(ctx context.Context, u *url.URL) string {
// setupGitEnv sets up the environment for the given command. This is used to
// pass configuration data to git and ssh and enables advanced cloning methods.
func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) {
// If there's no sshKeyFile argument to deal with, we can skip this
// entirely.
if sshKeyFile == "" {
return
}
const gitSSHCommand = "GIT_SSH_COMMAND="
var sshCmd []string

@@ -323,14 +328,12 @@ func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) {
sshCmd = []string{gitSSHCommand + "ssh"}
}

if sshKeyFile != "" {
// We have an SSH key temp file configured, tell ssh about this.
if runtime.GOOS == "windows" {
sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1)
}
sshCmd = append(sshCmd, "-i", sshKeyFile)
env = append(env, strings.Join(sshCmd, " "))
// We have an SSH key temp file configured, tell ssh about this.
if runtime.GOOS == "windows" {
sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1)
}
sshCmd = append(sshCmd, "-i", sshKeyFile)
env = append(env, strings.Join(sshCmd, " "))

cmd.Env = env
}
23 changes: 23 additions & 0 deletions get_git_test.go
Original file line number Diff line number Diff line change
@@ -699,6 +699,29 @@ func TestGitGetter_setupGitEnvWithExisting_sshKey(t *testing.T) {
}
}

func TestGitGetter_setupGitEnvWithNoKeyFile(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skipf("skipping on windows since the test requires sh")
return
}

// start with an existing ssh command configuration
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
defer os.Setenv("GIT_SSH_COMMAND", "")

cmd := exec.Command("/bin/sh", "-c", "echo $GIT_SSH_COMMAND")
setupGitEnv(cmd, "")
out, err := cmd.Output()
if err != nil {
t.Fatal(err)
}

actual := strings.TrimSpace(string(out))
if actual != "ssh -o StrictHostKeyChecking=no" {
t.Fatalf("unexpected GIT_SSH_COMMAND: %q", actual)
}
}

func TestGitGetter_subdirectory_symlink(t *testing.T) {
if !testHasGit {
t.Skip("git not found, skipping")