summaryrefslogtreecommitdiffstats
path: root/modules/git/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo.go')
-rw-r--r--modules/git/repo.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/git/repo.go b/modules/git/repo.go
index 8355f8811f..4be3164130 100644
--- a/modules/git/repo.go
+++ b/modules/git/repo.go
@@ -109,11 +109,13 @@ func OpenRepository(repoPath string) (*Repository, error) {
// CloneRepoOptions options when clone a repository
type CloneRepoOptions struct {
- Timeout time.Duration
- Mirror bool
- Bare bool
- Quiet bool
- Branch string
+ Timeout time.Duration
+ Mirror bool
+ Bare bool
+ Quiet bool
+ Branch string
+ Shared bool
+ NoCheckout bool
}
// Clone clones original repository to target path.
@@ -133,10 +135,17 @@ func Clone(from, to string, opts CloneRepoOptions) (err error) {
if opts.Quiet {
cmd.AddArguments("--quiet")
}
+ if opts.Shared {
+ cmd.AddArguments("-s")
+ }
+ if opts.NoCheckout {
+ cmd.AddArguments("--no-checkout")
+ }
+
if len(opts.Branch) > 0 {
cmd.AddArguments("-b", opts.Branch)
}
- cmd.AddArguments(from, to)
+ cmd.AddArguments("--", from, to)
if opts.Timeout <= 0 {
opts.Timeout = -1
@@ -181,6 +190,7 @@ type PushOptions struct {
Remote string
Branch string
Force bool
+ Env []string
}
// Push pushs local commits to given remote branch.
@@ -190,7 +200,7 @@ func Push(repoPath string, opts PushOptions) error {
cmd.AddArguments("-f")
}
cmd.AddArguments(opts.Remote, opts.Branch)
- _, err := cmd.RunInDir(repoPath)
+ _, err := cmd.RunInDirWithEnv(repoPath, opts.Env)
return err
}