Minor tweaks to submodules strings & consts
Rename consts internally and shorten help string a bit.
This commit is contained in:
parent
366e08ff40
commit
89aad82a31
|
|
@ -84,7 +84,7 @@ docker run -d \
|
||||||
| GIT_SYNC_BRANCH | `--branch` | the git branch to check out | "master" |
|
| 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_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_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_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_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 |
|
| GIT_SYNC_WAIT | `--wait` | the number of seconds between syncs | 0 |
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ var flRev = flag.String("rev", envString("GIT_SYNC_REV", "HEAD"),
|
||||||
var flDepth = flag.Int("depth", envInt("GIT_SYNC_DEPTH", 0),
|
var flDepth = flag.Int("depth", envInt("GIT_SYNC_DEPTH", 0),
|
||||||
"use a shallow clone with a history truncated to the specified number of commits")
|
"use a shallow clone with a history truncated to the specified number of commits")
|
||||||
var flSubmodules = flag.String("submodules", envString("GIT_SYNC_SUBMODULES", "recursive"),
|
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"),
|
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")
|
"the root directory for git-sync operations, under which --dest will be created")
|
||||||
|
|
@ -135,9 +135,9 @@ var (
|
||||||
const initTimeout = time.Second * 30
|
const initTimeout = time.Second * 30
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SubmoduleModeRecursive = "recursive"
|
submodulesRecursive = "recursive"
|
||||||
SubmoduleModeOff = "off"
|
submodulesShallow = "shallow"
|
||||||
SubmoduleModeShallow = "shallow"
|
submodulesOff = "off"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -259,9 +259,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch *flSubmodules {
|
switch *flSubmodules {
|
||||||
case SubmoduleModeRecursive, SubmoduleModeShallow, SubmoduleModeOff:
|
case submodulesRecursive, submodulesShallow, submodulesOff:
|
||||||
default:
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -540,10 +540,10 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
|
||||||
|
|
||||||
// Update submodules
|
// Update submodules
|
||||||
// NOTE: this works for repo with or without submodules.
|
// NOTE: this works for repo with or without submodules.
|
||||||
if submoduleMode != SubmoduleModeOff {
|
if submoduleMode != submodulesOff {
|
||||||
log.V(0).Info("updating submodules")
|
log.V(0).Info("updating submodules")
|
||||||
submodulesArgs := []string{"submodule", "update", "--init"}
|
submodulesArgs := []string{"submodule", "update", "--init"}
|
||||||
if submoduleMode == SubmoduleModeRecursive {
|
if submoduleMode == submodulesRecursive {
|
||||||
submodulesArgs = append(submodulesArgs, "--recursive")
|
submodulesArgs = append(submodulesArgs, "--recursive")
|
||||||
}
|
}
|
||||||
if depth != 0 {
|
if depth != 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue