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

Clone repositories with a depth of 1 #104

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ turbolift foreach --repos repoFile2.txt sed 's/pattern2/replacement2/g'
This creates a fork and clones all repositories listed in the `repos.txt` 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.

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
```
kurtmckee marked this conversation as resolved.
Show resolved Hide resolved

### 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
Loading