Skip to content

Commit 66f6387

Browse files
committed
fix: improve error handling for repository not found and empty remote
Signed-off-by: Noam Gal <[email protected]>
1 parent bd4e85f commit 66f6387

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/git/repository.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ func (o *CloneOptions) GetRepo(ctx context.Context) (Repository, fs.FS, error) {
228228

229229
r, err := clone(ctx, o)
230230
if err != nil {
231-
switch err {
232-
case transport.ErrRepositoryNotFound:
231+
switch {
232+
case errors.Is(err, transport.ErrRepositoryNotFound):
233233
if !o.CreateIfNotExist {
234234
return nil, nil, err
235235
}
@@ -241,7 +241,7 @@ func (o *CloneOptions) GetRepo(ctx context.Context) (Repository, fs.FS, error) {
241241
}
242242

243243
fallthrough // a new repo will always start as empty - we need to init it locally
244-
case transport.ErrEmptyRemoteRepository:
244+
case errors.Is(err, transport.ErrEmptyRemoteRepository):
245245
log.G(ctx).Info("empty repository, initializing a new one with specified remote")
246246
r, err = initRepo(ctx, o, defaultBranch)
247247
if err != nil {

0 commit comments

Comments
 (0)