From 6d38b4832b38ea0b2cc5977aba34536b2d79c3e3 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Wed, 13 Sep 2023 07:22:06 -0500 Subject: [PATCH 1/3] Clone repositories with a depth of 1 Closes #89 --- README.md | 12 +++++++++++- internal/github/github.go | 4 ++-- internal/github/github_test.go | 8 ++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fabf73c..c91b6cc 100644 --- a/README.md +++ b/README.md @@ -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 +``` ### Making changes diff --git a/internal/github/github.go b/internal/github/github.go index 880bc1f..fac1ef2 100644 --- a/internal/github/github.go +++ b/internal/github/github.go @@ -71,11 +71,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 { diff --git a/internal/github/github_test.go b/internal/github/github_test.go index f5032d4..e581f1a 100644 --- a/internal/github/github_test.go +++ b/internal/github/github_test.go @@ -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"}, }) } @@ -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"}, }) } @@ -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"}, }) } @@ -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"}, }) } From e95da2e3180273c185530905741bda463e7c753a Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Thu, 12 Oct 2023 06:35:23 -0500 Subject: [PATCH 2/3] Feedback: Use GH Markdown note syntax for visibility Co-authored-by: Richard North --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c91b6cc..28287f3 100644 --- a/README.md +++ b/README.md @@ -127,13 +127,14 @@ You may wish to skip the fork and work on the upstream repository branch directl > 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 -``` +> **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 From 19b199af5c296b676338fda48942ad0859028d1c Mon Sep 17 00:00:00 2001 From: Daniel Ranson <92924979+Dan7-7-7@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:18:04 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28287f3..32487b7 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ You may wish to skip the fork and work on the upstream repository branch directl > omit the `--no-fork` flag and let all the repositories be forked. > For now, it's an all-or-nothing scenario. -> **Note** +> [!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`: