Skip to content

Commit

Permalink
Revert "Revert "Clone repositories with a depth of 1 (#104)""
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan7-7-7 authored Jan 29, 2024
1 parent 39e21e5 commit 6392e13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ turbolift foreach --repos repoFile2.txt sed 's/pattern2/replacement2/g'
This creates a fork and clones all repositories listed in the `repos.txt` file (or the specified alternative repo file) into the `work` directory.
You may wish to skip the fork and work on the upstream repository branch directly with the flag `--no-fork`.

> NTLD: if one of the repositories in the list requires a fork to create a PR, omit the `--no-fork` flag and let all the repositories be forked. For now it's a all-or-nothing scenario.
> NTLD: if one of the repositories in the list requires a fork to create a PR,
> omit the `--no-fork` flag and let all the repositories be forked.
> For now, it's an all-or-nothing scenario.
> [!NOTE]
> Repositories are cloned with the git flag `--depth=1`.
> If you need the full commit history and tags, you can run the following command
> after running `turbolift clone`:
>
> ```shell
> turbolift foreach git fetch --unshallow --tags
> ```
### Making changes
Expand Down
4 changes: 2 additions & 2 deletions internal/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ func (r *RealGitHub) CreatePullRequest(output io.Writer, workingDir string, pr P
}

func (r *RealGitHub) ForkAndClone(output io.Writer, workingDir string, fullRepoName string) error {
return execInstance.Execute(output, workingDir, "gh", "repo", "fork", "--clone=true", fullRepoName)
return execInstance.Execute(output, workingDir, "gh", "repo", "fork", "--clone=true", fullRepoName, "--", "--depth=1")
}

func (r *RealGitHub) Clone(output io.Writer, workingDir string, fullRepoName string) error {
return execInstance.Execute(output, workingDir, "gh", "repo", "clone", fullRepoName)
return execInstance.Execute(output, workingDir, "gh", "repo", "clone", fullRepoName, "--", "--depth=1")
}

func (r *RealGitHub) ClosePullRequest(output io.Writer, workingDir string, branchName string) error {
Expand Down
8 changes: 4 additions & 4 deletions internal/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestItReturnsErrorOnFailedFork(t *testing.T) {
assert.Error(t, err)

fakeExecutor.AssertCalledWith(t, [][]string{
{"work/org", "gh", "repo", "fork", "--clone=true", "org/repo1"},
{"work/org", "gh", "repo", "fork", "--clone=true", "org/repo1", "--", "--depth=1"},
})
}

Expand All @@ -43,7 +43,7 @@ func TestItReturnsNilErrorOnSuccessfulFork(t *testing.T) {
assert.NoError(t, err)

fakeExecutor.AssertCalledWith(t, [][]string{
{"work/org", "gh", "repo", "fork", "--clone=true", "org/repo1"},
{"work/org", "gh", "repo", "fork", "--clone=true", "org/repo1", "--", "--depth=1"},
})
}

Expand All @@ -55,7 +55,7 @@ func TestItReturnsErrorOnFailedClone(t *testing.T) {
assert.Error(t, err)

fakeExecutor.AssertCalledWith(t, [][]string{
{"work/org", "gh", "repo", "clone", "org/repo1"},
{"work/org", "gh", "repo", "clone", "org/repo1", "--", "--depth=1"},
})
}

Expand All @@ -67,7 +67,7 @@ func TestItReturnsNilErrorOnSuccessfulClone(t *testing.T) {
assert.NoError(t, err)

fakeExecutor.AssertCalledWith(t, [][]string{
{"work/org", "gh", "repo", "clone", "org/repo1"},
{"work/org", "gh", "repo", "clone", "org/repo1", "--", "--depth=1"},
})
}

Expand Down

0 comments on commit 6392e13

Please sign in to comment.