summaryrefslogtreecommitdiff
path: root/core/command/cmd-pull.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/command/cmd-pull.go')
-rw-r--r--core/command/cmd-pull.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/command/cmd-pull.go b/core/command/cmd-pull.go
index 237303e..7fbcecc 100644
--- a/core/command/cmd-pull.go
+++ b/core/command/cmd-pull.go
@@ -42,7 +42,7 @@ type PullOptions struct {
}
// Pull ncorporates changes from a remote repository into the current branch.
-func Pull(e *git.RepoEntity, options PullOptions) (err error) {
+func Pull(r *git.Repository, options PullOptions) (err error) {
// here we configure pull operation
// default mode is go-git (this may be configured)
pullCmdMode = pullCmdModeNative
@@ -50,16 +50,16 @@ func Pull(e *git.RepoEntity, options PullOptions) (err error) {
switch pullCmdMode {
case pullCmdModeLegacy:
- err = pullWithGit(e, options)
+ err = pullWithGit(r, options)
return err
case pullCmdModeNative:
- err = pullWithGoGit(e, options)
+ err = pullWithGoGit(r, options)
return err
}
return nil
}
-func pullWithGit(e *git.RepoEntity, options PullOptions) (err error) {
+func pullWithGit(r *git.Repository, options PullOptions) (err error) {
args := make([]string, 0)
args = append(args, pullCommand)
// parse options to command line arguments
@@ -69,14 +69,14 @@ func pullWithGit(e *git.RepoEntity, options PullOptions) (err error) {
if options.Force {
args = append(args, "-f")
}
- if out, err := GenericGitCommandWithOutput(e.AbsPath, args); err != nil {
+ if out, err := GenericGitCommandWithOutput(r.AbsPath, args); err != nil {
return gerr.ParseGitError(out, err)
}
- e.SetState(git.Success)
- return e.Refresh()
+ r.SetState(git.Success)
+ return r.Refresh()
}
-func pullWithGoGit(e *git.RepoEntity, options PullOptions) (err error) {
+func pullWithGoGit(r *git.Repository, options PullOptions) (err error) {
opt := &gogit.PullOptions{
RemoteName: options.RemoteName,
SingleBranch: options.SingleBranch,
@@ -88,7 +88,7 @@ func pullWithGoGit(e *git.RepoEntity, options PullOptions) (err error) {
}
// if any credential is given, let's add it to the git.PullOptions
if len(options.Credentials.User) > 0 {
- protocol, err := git.AuthProtocol(e.Remote)
+ protocol, err := git.AuthProtocol(r.Remote)
if err != nil {
return err
}
@@ -104,7 +104,7 @@ func pullWithGoGit(e *git.RepoEntity, options PullOptions) (err error) {
if options.Progress {
opt.Progress = os.Stdout
}
- w, err := e.Repository.Worktree()
+ w, err := r.Repo.Worktree()
if err != nil {
return err
}
@@ -118,24 +118,24 @@ func pullWithGoGit(e *git.RepoEntity, options PullOptions) (err error) {
} else if err == memory.ErrRefHasChanged && pullTryCount < pullMaxTry {
pullTryCount++
log.Error("trying to fetch")
- if err := Fetch(e, FetchOptions{
+ if err := Fetch(r, FetchOptions{
RemoteName: options.RemoteName,
}); err != nil {
return err
}
- return Pull(e, options)
+ return Pull(r, options)
} else if strings.Contains(err.Error(), "SSH_AUTH_SOCK") {
// The env variable SSH_AUTH_SOCK is not defined, maybe git can handle this
- return pullWithGit(e, options)
+ return pullWithGit(r, options)
} else if err == transport.ErrAuthenticationRequired {
log.Warn(err.Error())
return gerr.ErrAuthenticationRequired
} else {
log.Warn(err.Error())
- return pullWithGit(e, options)
+ return pullWithGit(r, options)
}
}
- e.SetState(git.Success)
- return e.Refresh()
+ r.SetState(git.Success)
+ return r.Refresh()
}