0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-10 04:00:39 +00:00
wp-git-clone/plugin/utils.go
2023-12-23 00:59:23 +01:00

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, " "))
}