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

Conversation

kurtmckee
Copy link
Contributor

This PR attempts to introduce --depth=1 as a consistent git clone parameter, and documents how to fetch the rich git history if needed.

Please let me know if additional changes are needed, and thanks for your work on turbolift!


Note that I wasn't able to run make lint due to this error:

$ make test
--- lint all the things
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package goarch:
could not load export data: cannot import "internal/goarch" (unknown bexport format version -1
("u\x01\x00\x00...

Go developers may understand this, but I was lost. I used the pre-commit config I introduced in #103 to at least lint the code, and it passed. I was also able to run make test (though this error printed first) and make build.

I recommend relying on pre-commit for linting and fixing, due to its ability to standardize environments.

I also recommend introducing a changelog to the repo.

Closes #89

README.md Outdated Show resolved Hide resolved
rnorth
rnorth previously approved these changes Oct 12, 2023
Copy link
Collaborator

@rnorth rnorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to us. Aside from a small README suggestion, one thing we think could be different would be a flag for turbolift clone to not do a shallow clone, instead of the suggested foreach unshallow.

However, we're comfortable with merging as-is and coming back to add that flag later if there is proven demand for it.

README.md Outdated Show resolved Hide resolved
@Dan7-7-7 Dan7-7-7 merged commit c45db62 into Skyscanner:main Nov 9, 2023
5 checks passed
@rnorth
Copy link
Collaborator

rnorth commented Nov 9, 2023

Thanks for contribution @kurtmckee!

@kurtmckee kurtmckee deleted the default-to-shallow-clones-issue-89 branch November 9, 2023 13:33
@danielvoros-form3
Copy link

Heya! 👋 I think this is causing issues when trying to create PRs. --depth 1 implies --single-branch which results in a refspec that only creates a remote tracking branch for the default branch:

fetch = +refs/heads/master:refs/remotes/origin/master

This means that even if you set the upstream of your local branch and push it, the remote branch will not be tracked:

# Push local branch and ask for tracking:
> git push -u origin HEAD
branch 'test' set up to track 'origin/test'.
...

# See how there's no remote tracking branch:
> git branch --remote
  origin/HEAD -> origin/master
  origin/master

# Remote tracking branch also not showing up here:
> git branch -vvv
* test   4cf840b Merge pull request #121 from ...
  master 4cf840b [origin/master] Merge pull request #121 from ...

Note that the branch is actually pushed, but then gh is not aware of the tracking information, so create-prs will fail with:

> turbolift create-prs -v
  OK   Reading campaign data (repos.txt)

  OK   Pushing changes in form3tech/infrastructure-k8s-example-app to origin

     Executing: git [push -u origin dvoros-bootstrap-interval-bump] in work/form3tech/infrastructure-k8s-example-app
         Everything up-to-date
         branch 'dvoros-bootstrap-interval-bump' set up to track 'origin/dvoros-bootstrap-interval-bump'.
 FAIL  Creating PR in form3tech/infrastructure-k8s-example-app: error: exit status 1. Stderr: aborted: you must first push the current branch to a remote, or use the --head flag

     Executing: gh [pr create --title ... --body ... --repo ...]
 WARN  turbolift create-prs completed with errors (0 OK, 0 skipped, 1 errored)

Verified that the same works with 2.2.0. Maybe we should add --no-single-branch as well to the gh repo clone call? 🤔

@kurtmckee
Copy link
Contributor Author

Well, blast and confound.

I see the error output from gh pr create also suggests to add the --head flag; do you know if that would be a wise addition in general (regardless of adding the --no-single-branch flag to gh repo clone)?

Dan7-7-7 pushed a commit that referenced this pull request Nov 13, 2023
@Dan7-7-7
Copy link
Collaborator

In addition to the above, I'm realising that this may cause issues with refreshing from upstream for outdated forks. We should perhaps revert this change while we work out a fix for these issues.

Dan7-7-7 added a commit that referenced this pull request Nov 13, 2023
@sledigabel
Copy link
Contributor

FWIW it would appear the --no-single-branch is the way to go here, and adding it to the list of parameters sent to gh should do the trick.

link
git doc

@Dan7-7-7
Copy link
Collaborator

@kurtmckee would you like to do the honours and add this feature like before with the addition of --no-single-branch?

@kurtmckee
Copy link
Contributor Author

@Dan7-7-7 Sorry for the delay in responding. I don't have bandwidth to tackle this, but it looks like your PR adds --no-single-branch! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option for shallow clone for repos with large commit histories
6 participants