remove -t argument from `git remote add` command. fix #5

This commit is contained in:
Massaki Archambault 2021-08-13 13:40:22 -04:00
parent fb11c3f5c5
commit 7fad1c2b43
2 changed files with 28 additions and 5 deletions

View File

@ -35,10 +35,9 @@ git:
pull_method: http
# Must be set to either "init", or "clone".
# If set to "init", the local clone will be initialized with `git init` and set to track the default branch. (fastest)
# If set to "clone", the local clone will be initialized with `git clone`. (slowest)
# NOTE: If set to "init", the local clone will appear empty. Running `git pull` will download the files from the git server.
# It's highly recommended to leave this setting on "init".
# If set to "init", the local copy will be initialized with `git init` and the remote is configured manually. The git server is nerver queried. (fast)
# If set to "clone", the local copy will be initialized with `git clone`. (slow)
# NOTE: If set to "init", the local clone will appear empty. Running `git pull master` will download the files from the git server.
on_clone: init
# If set to true, the local clone will automatically run `git pull` in the local clone if it's on the default branch and the worktree is clean.

View File

@ -49,7 +49,7 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
_, err = utils.ExecProcessInDir(
gcp.dst, // workdir
"git", "remote", "add",
"-t", gcp.defaultBranch,
"-m", gcp.defaultBranch,
"--",
c.RemoteName, // name
gcp.url, // url
@ -57,6 +57,30 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
if err != nil {
return fmt.Errorf("failed to setup remote %v in git repo %v: %v", gcp.url, gcp.dst, err)
}
// Configure the default branch
_, err = utils.ExecProcessInDir(
gcp.dst, // workdir
"git", "config", "--local",
"--",
fmt.Sprintf("branch.%s.remote", gcp.defaultBranch), // key
c.RemoteName, // value
)
if err != nil {
return fmt.Errorf("failed to setup default branch remote in git repo %v: %v", gcp.dst, err)
}
_, err = utils.ExecProcessInDir(
gcp.dst, // workdir
"git", "config", "--local",
"--",
fmt.Sprintf("branch.%s.merge", gcp.defaultBranch), // key
fmt.Sprintf("refs/heads/%s", gcp.defaultBranch), // value
)
if err != nil {
return fmt.Errorf("failed to setup default branch merge in git repo %v: %v", gcp.dst, err)
}
} else {
// Clone the repo
_, err := utils.ExecProcess(