mirror of
https://github.com/thegeeklab/wp-git-clone.git
synced 2024-11-09 17:50:39 +00:00
29 lines
662 B
Go
29 lines
662 B
Go
|
package plugin
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strings"
|
||
|
|
||
|
"github.com/cenkalti/backoff/v4"
|
||
|
"golang.org/x/sys/execabs"
|
||
|
)
|
||
|
|
||
|
// shouldRetry returns true if the command should be re-executed. Currently
|
||
|
// this only returns true if the remote ref does not exist.
|
||
|
func shouldRetry(s string) bool {
|
||
|
return strings.Contains(s, "find remote ref")
|
||
|
}
|
||
|
|
||
|
func newBackoff(maxRetries uint64) backoff.BackOff {
|
||
|
b := backoff.NewExponentialBackOff()
|
||
|
b.InitialInterval = daemonBackoffInitialInterval
|
||
|
b.Multiplier = daemonBackoffMultiplier
|
||
|
|
||
|
return backoff.WithMaxRetries(b, maxRetries)
|
||
|
}
|
||
|
|
||
|
func trace(cmd *execabs.Cmd) {
|
||
|
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
||
|
}
|