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

Clean directory before cloning git repo #3783

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

aryan9600
Copy link
Member

@aryan9600 aryan9600 commented Apr 11, 2023

Remove all files/subdirs from the directory we are cloning into. This is needed because go-git returns a repository already exists error if the directory is non-empty, which is possible since we retry cloning (into the same dir) if the first attempt fails.

before:

❯ flux bootstrap git --url=ssh://git@github.com/aryan9600/non-existent-repo.git --branch=main
► cloning branch "main" from Git repository "ssh://git@github.com/aryan9600/non-existent-repo.git"
⚠️  clone failure: unable to clone: repository not found: git repository: 'ssh://git@github.com/aryan9600/non-existent-repo.git'
⚠️  clone failure: unable to clone 'ssh://git@github.com/aryan9600/non-existent-repo.git': repository already exists
✗ failed to clone repository: unable to clone 'ssh://git@github.com/aryan9600/non-existent-repo.git': repository already exists

after:

❯ ./bin/flux bootstrap git --url=ssh://git@github.com/aryan9600/non-existent-repo.git --branch=main
► cloning branch "main" from Git repository "ssh://git@github.com/aryan9600/non-existent-repo.git"
⚠️  clone failure: unable to clone: repository not found: git repository: 'ssh://git@github.com/aryan9600/non-existent-repo.git'
⚠️  clone failure: unable to clone: repository not found: git repository: 'ssh://git@github.com/aryan9600/non-existent-repo.git'
✗ failed to clone repository: unable to clone: repository not found: git repository: 'ssh://git@github.com/aryan9600/non-existent-repo.git'

@aryan9600 aryan9600 marked this pull request as draft April 11, 2023 08:28
@aryan9600 aryan9600 marked this pull request as ready for review April 11, 2023 08:50
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @aryan9600 please rebase

Remove all files/subdirs from the directory we are cloning into. This is
needed because go-git returns a `repository already exists` error if
the directory is non-empty, which is possible since we retry cloning
(into the same dir) if the first attempt fails.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
@stefanprodan stefanprodan added bug Something isn't working area/bootstrap Bootstrap related issues and pull requests labels Apr 12, 2023
@stefanprodan stefanprodan added this to the Bootstrap GA milestone Apr 12, 2023
@stefanprodan stefanprodan merged commit 9a59a90 into fluxcd:main Apr 12, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bootstrap Bootstrap related issues and pull requests bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants