Skip to content

Commit

Permalink
add check if repo exists
Browse files Browse the repository at this point in the history
  • Loading branch information
malikchaya2 committed Dec 13, 2024
1 parent bcedb62 commit 876a296
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions operations/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ type cloneOptions struct {
}

func clone(opts cloneOptions) error {
// Check repository existence if no token is provided
if opts.token == "" {
resp, err := http.Get(thirdparty.FormGitURLForApp("github.com", opts.owner, opts.repository, opts.token))
if err != nil {
return errors.Errorf("failed to check if %s/%s exists: %v", opts.owner, opts.repository, err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return errors.Errorf("repository does not exist or is private an no token was provided: %d", resp.StatusCode)
}
}
var cloneArgs []string
// clone the repo first
if opts.isAppToken {
Expand Down

0 comments on commit 876a296

Please sign in to comment.