0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-14 19:30:40 +00:00
wp-git-clone/plugin/utils.go

29 lines
662 B
Go
Raw Normal View History

2023-12-22 23:59:23 +00:00
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, " "))
}