Compare commits
1 Commits
e3d5bb6a3e
...
c642efcf8c
Author | SHA1 | Date | |
---|---|---|---|
c642efcf8c |
@ -28,17 +28,17 @@ func gitCloneIgnoreErr(err error) bool {
|
||||
// Clone runs a git clone which accounts for different default branches.
|
||||
func Clone(dir, url string) error {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
ctx, cancelCtx := context.WithCancel(ctx)
|
||||
|
||||
sigIntCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigIntCh, os.Interrupt)
|
||||
defer func() {
|
||||
signal.Stop(sigIntCh)
|
||||
cancelCtx()
|
||||
}()
|
||||
|
||||
errCh := make(chan error)
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
defer func() {
|
||||
signal.Stop(c)
|
||||
cancel()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
log.Debugf("git clone: %s", url)
|
||||
@ -88,8 +88,8 @@ func Clone(dir, url string) error {
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-c:
|
||||
cancel()
|
||||
case <-sigIntCh:
|
||||
cancelCtx()
|
||||
fmt.Println() // NOTE(d1): newline after ^C
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
return fmt.Errorf("unable to clean up git clone of %s: %s", dir, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user