Minor tweaks to submodules strings & consts

Rename consts internally and shorten help string a bit.
This commit is contained in:
Tim Hockin 2020-07-31 08:49:09 -07:00
parent 366e08ff40
commit 89aad82a31
2 changed files with 9 additions and 9 deletions

View File

@ -84,7 +84,7 @@ docker run -d \
| GIT_SYNC_BRANCH | `--branch` | the git branch to check out | "master" |
| GIT_SYNC_REV | `--rev` | the git revision (tag or hash) to check out | "HEAD" |
| GIT_SYNC_DEPTH | `--depth` | use a shallow clone with a history truncated to the specified number of commits | 0 |
| GIT_SYNC_SUBMODULES | `--submodules` | submodule clone option. One of recursive, shallow (does not use --recursive flag), or off (no submodule cloning) | recursive |
| GIT_SYNC_SUBMODULES | `--submodules` | git submodule behavior: one of 'recursive', 'shallow', or 'off' | recursive |
| GIT_SYNC_ROOT | `--root` | the root directory for git-sync operations, under which --dest will be created | "$HOME/git" |
| GIT_SYNC_DEST | `--dest` | the name of (a symlink to) a directory in which to check-out files under --root (defaults to the leaf dir of --repo) | "" |
| GIT_SYNC_WAIT | `--wait` | the number of seconds between syncs | 0 |

View File

@ -55,7 +55,7 @@ var flRev = flag.String("rev", envString("GIT_SYNC_REV", "HEAD"),
var flDepth = flag.Int("depth", envInt("GIT_SYNC_DEPTH", 0),
"use a shallow clone with a history truncated to the specified number of commits")
var flSubmodules = flag.String("submodules", envString("GIT_SYNC_SUBMODULES", "recursive"),
"Configure submodule behavior - options are 'recursive', 'shallow' and 'off'.")
"git submodule behavior: one of 'recursive', 'shallow', or 'off'")
var flRoot = flag.String("root", envString("GIT_SYNC_ROOT", envString("HOME", "")+"/git"),
"the root directory for git-sync operations, under which --dest will be created")
@ -135,9 +135,9 @@ var (
const initTimeout = time.Second * 30
const (
SubmoduleModeRecursive = "recursive"
SubmoduleModeOff = "off"
SubmoduleModeShallow = "shallow"
submodulesRecursive = "recursive"
submodulesShallow = "shallow"
submodulesOff = "off"
)
func init() {
@ -259,9 +259,9 @@ func main() {
}
switch *flSubmodules {
case SubmoduleModeRecursive, SubmoduleModeShallow, SubmoduleModeOff:
case submodulesRecursive, submodulesShallow, submodulesOff:
default:
fmt.Fprintf(os.Stderr, "ERROR: --submodules must be one of %s, %s or %s, but recieved %s", SubmoduleModeRecursive, SubmoduleModeOff, SubmoduleModeShallow, *flSubmodules)
fmt.Fprintf(os.Stderr, "ERROR: --submodules must be one of %q, %q, or %q", submodulesRecursive, submodulesShallow, submodulesOff)
os.Exit(1)
}
@ -540,10 +540,10 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
// Update submodules
// NOTE: this works for repo with or without submodules.
if submoduleMode != SubmoduleModeOff {
if submoduleMode != submodulesOff {
log.V(0).Info("updating submodules")
submodulesArgs := []string{"submodule", "update", "--init"}
if submoduleMode == SubmoduleModeRecursive {
if submoduleMode == submodulesRecursive {
submodulesArgs = append(submodulesArgs, "--recursive")
}
if depth != 0 {