diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-07 01:34:16 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-07 01:34:16 +0300 |
| commit | c4943925d95315cccd42ba8a8101467956479b82 (patch) | |
| tree | b9ffc6676ef8f0bf6fa8d2ecd6d7866340ea3d04 | |
| parent | Merge pull request #25 from isacikgoz/develop (diff) | |
| parent | Merge remote-tracking branch 'origin/develop' into develop (diff) | |
| download | gitbatch-c4943925d95315cccd42ba8a8101467956479b82.tar.gz | |
Merge pull request #26 from isacikgoz/develop
Develop
| -rw-r--r-- | pkg/git/branch.go | 84 | ||||
| -rw-r--r-- | pkg/git/commands.go | 73 | ||||
| -rw-r--r-- | pkg/git/commit.go | 4 | ||||
| -rw-r--r-- | pkg/git/fetch.go | 44 | ||||
| -rw-r--r-- | pkg/git/git-commands.go | 144 | ||||
| -rw-r--r-- | pkg/git/load.go | 5 | ||||
| -rw-r--r-- | pkg/git/merge.go | 37 | ||||
| -rw-r--r-- | pkg/git/remotebranch.go | 19 | ||||
| -rw-r--r-- | pkg/git/repository.go | 57 | ||||
| -rw-r--r-- | pkg/git/rev-list.go | 42 | ||||
| -rw-r--r-- | pkg/gui/gui.go | 3 | ||||
| -rw-r--r-- | pkg/queue/job.go | 68 | ||||
| -rw-r--r-- | pkg/queue/queue.go | 61 |
13 files changed, 336 insertions, 305 deletions
diff --git a/pkg/git/branch.go b/pkg/git/branch.go index 204ddb2..4f54ced 100644 --- a/pkg/git/branch.go +++ b/pkg/git/branch.go @@ -7,6 +7,7 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing" "regexp" "strings" + "strconv" ) // Branch is the wrapper of go-git's Reference struct. In addition to that, it @@ -46,7 +47,25 @@ func (entity *RepoEntity) loadLocalBranches() error { defer branches.Close() branches.ForEach(func(b *plumbing.Reference) error { if b.Type() == plumbing.HashReference { - push, pull := UpstreamDifferenceCount(entity.AbsPath) + var push, pull string + pushables, err := RevList(entity, RevListOptions{ + Ref1: "@{u}", + Ref2: "HEAD", + }) + if err != nil { + push = pushables[0] + } else { + push = strconv.Itoa(len(pushables)) + } + pullables, err := RevList(entity, RevListOptions{ + Ref1: "HEAD", + Ref2: "@{u}", + }) + if err != nil { + pull = pullables[0] + } else { + pull = strconv.Itoa(len(pullables)) + } clean := entity.isClean() branch := &Branch{Name: b.Name().Short(), Reference: b, Pushables: push, Pullables: pull, Clean: clean} lbs = append(lbs, branch) @@ -109,7 +128,7 @@ func (entity *RepoEntity) Checkout(branch *Branch) error { entity.loadCommits() entity.Commit = entity.Commits[0] entity.Branch = branch - entity.Branch.Pushables, entity.Branch.Pullables = UpstreamDifferenceCount(entity.AbsPath) + entity.RefreshPushPull() // TODO: same code on 3 different occasion, maybe something wrong? // make this conditional on global scale if err = entity.Remote.switchRemoteBranch(entity.Remote.Name + "/" + entity.Branch.Name); err != nil { @@ -141,38 +160,59 @@ func (entity *RepoEntity) isClean() bool { // RefreshPushPull refreshes the active branchs pushable and pullable count func (entity *RepoEntity) RefreshPushPull() { - entity.Branch.Pushables, entity.Branch.Pullables = UpstreamDifferenceCount(entity.AbsPath) + pushables, err := RevList(entity, RevListOptions{ + Ref1: "@{u}", + Ref2: "HEAD", + }) + if err != nil { + entity.Branch.Pushables = pushables[0] + } else { + entity.Branch.Pushables = strconv.Itoa(len(pushables)) + } + pullables, err := RevList(entity, RevListOptions{ + Ref1: "HEAD", + Ref2: "@{u}", + }) + if err != nil { + entity.Branch.Pullables = pullables[0] + } else { + entity.Branch.Pullables = strconv.Itoa(len(pullables)) + } } // this function creates the commit entities according to active branchs diffs // to *its* configured upstream func (entity *RepoEntity) pullDiffsToUpstream() ([]*Commit, error) { remoteCommits := make([]*Commit, 0) - hashes := UpstreamPullDiffs(entity.AbsPath) - re := regexp.MustCompile(`\r?\n`) - if hashes != "?" { - sliced := strings.Split(hashes, "\n") - for _, s := range sliced { - if len(s) == 40 { - commit := &Commit{ - Hash: s, - Author: GitShowEmail(entity.AbsPath, s), - Message: re.ReplaceAllString(GitShowBody(entity.AbsPath, s), " "), - Time: GitShowDate(entity.AbsPath, s), - CommitType: RemoteCommit, - } - remoteCommits = append(remoteCommits, commit) + pullables, err := RevList(entity, RevListOptions{ + Ref1: "HEAD", + Ref2: "@{u}", + }) + if err != nil { + // possibly found nothing or no upstream set + } else { + re := regexp.MustCompile(`\r?\n`) + for _, s := range pullables { + commit := &Commit{ + Hash: s, + Author: GitShowEmail(entity.AbsPath, s), + Message: re.ReplaceAllString(GitShowBody(entity.AbsPath, s), " "), + Time: GitShowDate(entity.AbsPath, s), + CommitType: RemoteCommit, } + remoteCommits = append(remoteCommits, commit) } } return remoteCommits, nil } func (entity *RepoEntity) pushDiffsToUpstream() ([]string, error) { - sliced := make([]string, 0) - hashes := UpstreamPushDiffs(entity.AbsPath) - if hashes != "?" { - sliced = strings.Split(hashes, "\n") + pushables, err := RevList(entity, RevListOptions{ + Ref1: "@{u}", + Ref2: "HEAD", + }) + if err != nil { + return make([]string, 0), nil } - return sliced, nil + return pushables, nil } diff --git a/pkg/git/commands.go b/pkg/git/commands.go new file mode 100644 index 0000000..0a1820b --- /dev/null +++ b/pkg/git/commands.go @@ -0,0 +1,73 @@ +package git + +import ( + "github.com/isacikgoz/gitbatch/pkg/helpers" +) + +// GenericGitCommand runs any git command without expecting output +func GenericGitCommand(repoPath string, args []string) error { + _, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return err + } + return nil +} + +// GenericGitCommand runs any git command with returning output +func GenericGitCommandWithOutput(repoPath string, args []string) (string, error) { + out, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return "?", err + } + return helpers.TrimTrailingNewline(out), nil +} + +// GitShow is conventional git show command without any argument +func GitShow(repoPath, hash string) string { + args := []string{"show", hash} + diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return "?" + } + return diff +} + +// GitShowEmail gets author's e-mail with git show command +func GitShowEmail(repoPath, hash string) string { + args := []string{"show", "--quiet", "--pretty=format:%ae", hash} + diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return "?" + } + return diff +} + +// GitShowBody gets body of the commit with git show +func GitShowBody(repoPath, hash string) string { + args := []string{"show", "--quiet", "--pretty=format:%B", hash} + diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return err.Error() + } + return diff +} + +// GitShowDate gets commit's date with git show as string +func GitShowDate(repoPath, hash string) string { + args := []string{"show", "--quiet", "--pretty=format:%ai", hash} + diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) + if err != nil { + return "?" + } + return diff +} + +// StatusWithGit returns the plaintext short status of the repo +func (entity *RepoEntity) StatusWithGit() string { + args := []string{"status"} + status, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) + if err != nil { + return "?" + } + return status +} diff --git a/pkg/git/commit.go b/pkg/git/commit.go index 13b0f54..8694f1a 100644 --- a/pkg/git/commit.go +++ b/pkg/git/commit.go @@ -24,9 +24,9 @@ type Commit struct { type CommitType string const ( - // LocalCommit is the commit that recorded locally + // LocalCommit is the commit that not pushed to remote branch LocalCommit CommitType = "local" - // RemoteCommit is the commit that not merged to local branch + // EvenCommit is the commit that recorded locally EvenCommit CommitType = "even" // RemoteCommit is the commit that not merged to local branch RemoteCommit CommitType = "remote" diff --git a/pkg/git/fetch.go b/pkg/git/fetch.go new file mode 100644 index 0000000..1b3bb69 --- /dev/null +++ b/pkg/git/fetch.go @@ -0,0 +1,44 @@ +package git + +import ( + log "github.com/sirupsen/logrus" +) + +var fetchCommand = "fetch" + +type FetchOptions struct { + // Name of the remote to fetch from. Defaults to origin. + RemoteName string + // Before fetching, remove any remote-tracking references that no longer + // exist on the remote. + Prune bool + // Show what would be done, without making any changes. + DryRun bool + // Force allows the fetch to update a local branch even when the remote + // branch does not descend from it. + Force bool +} + +// Fetch branches refs from one or more other repositories, along with the +// objects necessary to complete their histories +func Fetch(entity *RepoEntity, options FetchOptions) error { + args := make([]string, 0) + args = append(args, fetchCommand) + if len(options.RemoteName) > 0 { + args = append(args, options.RemoteName) + } + if options.Prune { + args = append(args, "-p") + } + if options.Force { + args = append(args, "-f") + } + if options.DryRun { + args = append(args, "--dry-run") + } + if err := GenericGitCommand(entity.AbsPath, args); err != nil { + log.Warn("Error while fetching") + return err + } + return nil +}
\ No newline at end of file diff --git a/pkg/git/git-commands.go b/pkg/git/git-commands.go deleted file mode 100644 index fdcec12..0000000 --- a/pkg/git/git-commands.go +++ /dev/null @@ -1,144 +0,0 @@ -package git - -import ( - "strings" - - "github.com/isacikgoz/gitbatch/pkg/helpers" -) - -// UpstreamDifferenceCount checks how many pushables/pullables there are for the -// current branch -// TODO: get pull pushes to remote branch vs local branch -func UpstreamDifferenceCount(repoPath string) (string, string) { - args := []string{"rev-list", "@{u}..HEAD", "--count"} - pushableCount, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?", "?" - } - args = []string{"rev-list", "HEAD..@{u}", "--count"} - pullableCount, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?", "?" - } - return strings.TrimSpace(pushableCount), strings.TrimSpace(pullableCount) -} - -// UpstreamPushDiffs returns the hash list -func UpstreamPushDiffs(repoPath string) string { - args := []string{"rev-list", "@{u}..HEAD"} - pushableCount, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?" - } - return pushableCount -} - -// UpstreamPullDiffs returns the hash list -func UpstreamPullDiffs(repoPath string) string { - args := []string{"rev-list", "HEAD..@{u}"} - pullableCount, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?" - } - return pullableCount -} - -// GitShow is conventional git show command without any argument -func GitShow(repoPath, hash string) string { - args := []string{"show", hash} - diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?" - } - return diff -} - -// GitShowEmail gets author's e-mail with git show command -func GitShowEmail(repoPath, hash string) string { - args := []string{"show", "--quiet", "--pretty=format:%ae", hash} - diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?" - } - return diff -} - -// GitShowBody gets body of the commit with git show -func GitShowBody(repoPath, hash string) string { - args := []string{"show", "--quiet", "--pretty=format:%B", hash} - diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return err.Error() - } - return diff -} - -// GitShowDate gets commit's date with git show as string -func GitShowDate(repoPath, hash string) string { - args := []string{"show", "--quiet", "--pretty=format:%ai", hash} - diff, err := helpers.RunCommandWithOutput(repoPath, "git", args) - if err != nil { - return "?" - } - return diff -} - -// FetchWithGit is wrapper of the git fetch <remote> command -func (entity *RepoEntity) FetchWithGit(remote string) error { - args := []string{"fetch", remote} - _, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return err - } - return nil -} - -// DryFetchAndPruneWithGit is wrapper of the git fetch <remote> --prune --dry-run command -func (entity *RepoEntity) DryFetchAndPruneWithGit(remote string) string { - args := []string{"fetch", remote, "--prune", "--dry-run"} - d, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return "?" - } - return d -} - -// PullWithGit is wrapper of the git pull <remote>/<branch> command -func (entity *RepoEntity) PullWithGit(remote, branch string) error { - args := []string{"pull", remote, branch} - _, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return err - } - return nil -} - -// MergeWithGit is wrapper of the git merge <branch> command -func (entity *RepoEntity) MergeWithGit(mergeFrom string) error { - args := []string{"merge", mergeFrom} - _, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return err - } - return nil -} - -// CheckoutWithGit is wrapper of the git checkout <branch> command -func (entity *RepoEntity) CheckoutWithGit(branch string) error { - args := []string{"checkout", branch} - _, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return err - } - return nil -} - -// StatusWithGit returns the plaintext short status of the repo -func (entity *RepoEntity) StatusWithGit() string { - args := []string{"status"} - status, err := helpers.RunCommandWithOutput(entity.AbsPath, "git", args) - if err != nil { - return "?" - } - return status -} diff --git a/pkg/git/load.go b/pkg/git/load.go index 69bff60..e35e1c1 100644 --- a/pkg/git/load.go +++ b/pkg/git/load.go @@ -2,6 +2,8 @@ package git import ( log "github.com/sirupsen/logrus" + + "errors" "sync" ) @@ -39,5 +41,8 @@ func LoadRepositoryEntities(directories []string) (entities []*RepoEntity, err e // wait until the wait counter is zero, this happens if all goroutines have // finished wg.Wait() + if len(entities) == 0 { + return entities, errors.New("There are no git repositories at given path(s)") + } return entities, nil } diff --git a/pkg/git/merge.go b/pkg/git/merge.go new file mode 100644 index 0000000..f2a8fae --- /dev/null +++ b/pkg/git/merge.go @@ -0,0 +1,37 @@ +package git + +import ( + log "github.com/sirupsen/logrus" +) + +var mergeCommand = "merge" + +type MergeOptions struct { + // Name of the branch to merge with. + BranchName string + // Be verbose. + Verbose bool + // With true do not show a diffstat at the end of the merge. + NoStat bool +} + +// Merge incorporates changes from the named commits or branches into the +// current branch +func Merge(entity *RepoEntity, options MergeOptions) error { + args := make([]string, 0) + args = append(args, mergeCommand) + if len(options.BranchName) > 0 { + args = append(args, options.BranchName) + } + if options.Verbose { + args = append(args, "-v") + } + if options.NoStat { + args = append(args, "-n") + } + if err := GenericGitCommand(entity.AbsPath, args); err != nil { + log.Warn("Error while merging") + return err + } + return nil +}
\ No newline at end of file diff --git a/pkg/git/remotebranch.go b/pkg/git/remotebranch.go index c58a6d4..8ab737f 100644 --- a/pkg/git/remotebranch.go +++ b/pkg/git/remotebranch.go @@ -2,10 +2,8 @@ package git import ( "errors" - "regexp" "strings" - "github.com/isacikgoz/gitbatch/pkg/helpers" log "github.com/sirupsen/logrus" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/storer" @@ -106,20 +104,3 @@ func (remote *Remote) switchRemoteBranch(remoteBranchName string) error { } return errors.New("Remote branch not found.") } - -func deletedRemoteBranches(entity *RepoEntity, remote string) ([]string, error) { - deletedRemoteBranches := make([]string, 0) - output := entity.DryFetchAndPruneWithGit(remote) - output = helpers.TrimTrailingNewline(output) - re := regexp.MustCompile(` - \[deleted\].+-> `) - if output != "?" { - sliced := strings.Split(output, "\n") - for _, s := range sliced { - if re.MatchString(s) { - ss := re.ReplaceAllString(s, "") - deletedRemoteBranches = append(deletedRemoteBranches, ss) - } - } - } - return deletedRemoteBranches, nil -} diff --git a/pkg/git/repository.go b/pkg/git/repository.go index 6918371..e75281c 100644 --- a/pkg/git/repository.go +++ b/pkg/git/repository.go @@ -99,62 +99,6 @@ func InitializeRepository(directory string) (entity *RepoEntity, err error) { return entity, nil } -// Pull incorporates changes from a remote repository into the current branch. -// In its default mode, git pull is shorthand for git fetch followed by git -// merge <branch> -func (entity *RepoEntity) Pull() error { - // TODO: Migrate this code to src-d/go-git - // 2018-11-25: tried but it fails, will investigate. - rm := entity.Remote.Name - if err := entity.FetchWithGit(rm); err != nil { - log.WithFields(log.Fields{ - "remote": rm, - }).Trace("Error while fetching remote") - return err - } - entity.Checkout(entity.Branch) - if err := entity.MergeWithGit(entity.Remote.Branch.Name); err != nil { - log.WithFields(log.Fields{ - "branch": entity.Remote.Branch.Name, - }).Trace("Error while merge to branch") - entity.Refresh() - return err - } - entity.Refresh() - entity.Checkout(entity.Branch) - return nil -} - -// Fetch branches refs from one or more other repositories, along with the -// objects necessary to complete their histories -func (entity *RepoEntity) Fetch() error { - rm := entity.Remote.Name - if err := entity.FetchWithGit(rm); err != nil { - log.WithFields(log.Fields{ - "remote": rm, - }).Trace("Error while fetching remote") - return err - } - entity.Refresh() - entity.Checkout(entity.Branch) - return nil -} - -// Merge incorporates changes from the named commits or branches into the -// current branch -func (entity *RepoEntity) Merge() error { - entity.Checkout(entity.Branch) - if err := entity.MergeWithGit(entity.Remote.Branch.Name); err != nil { - log.WithFields(log.Fields{ - "branch": entity.Remote.Branch.Name, - }).Trace("Error while merge to branch") - entity.Refresh() - return err - } - entity.Refresh() - return nil -} - // Refresh the belongings of a repositoriy, this function is called right after // fetch/pull/merge operations func (entity *RepoEntity) Refresh() error { @@ -174,6 +118,7 @@ func (entity *RepoEntity) Refresh() error { if err := entity.loadLocalBranches(); err != nil { return err } + entity.RefreshPushPull() if err := entity.loadCommits(); err != nil { return err } diff --git a/pkg/git/rev-list.go b/pkg/git/rev-list.go new file mode 100644 index 0000000..f9f45da --- /dev/null +++ b/pkg/git/rev-list.go @@ -0,0 +1,42 @@ +package git + +import ( + "strings" + + log "github.com/sirupsen/logrus" +) + +var revlistCommand = "rev-list" +var hashLength = 40 + +type RevListOptions struct { + // Ref1 is the first reference hash to link + Ref1 string + // Ref2 is the second reference hash to link + Ref2 string +} + +// RevList returns the commit hashes that are links from the given commit(s). +// The output is given in reverse chronological order by default. +func RevList(entity *RepoEntity, options RevListOptions) ([]string, error) { + args := make([]string, 0) + args = append(args, revlistCommand) + if len(options.Ref1) > 0 && len(options.Ref2) > 0 { + arg1 := options.Ref1+".."+options.Ref2 + args = append(args, arg1) + } + out, err := GenericGitCommandWithOutput(entity.AbsPath, args) + if err != nil { + log.Warn("Error while rev-list command") + return []string{out}, err + } + hashes := strings.Split(out, "\n") + for _, hash := range hashes { + if len(hash) != hashLength { + return make([]string, 0), nil + } else { + break + } + } + return hashes, nil +}
\ No newline at end of file diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index b781ba5..0598383 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -110,7 +110,8 @@ func (gui *Gui) Run() error { } rs, err := git.LoadRepositoryEntities(g_ui.State.Directories) if err != nil { - log.Error("Error while loading repositories.") + g.Close() + log.Fatal(err) return } g_ui.State.Repositories = rs diff --git a/pkg/queue/job.go b/pkg/queue/job.go new file mode 100644 index 0000000..e2dd94e --- /dev/null +++ b/pkg/queue/job.go @@ -0,0 +1,68 @@ +package queue + +import ( + "time" + + "github.com/isacikgoz/gitbatch/pkg/git" +) + +// Job relates the type of the operation and the entity +type Job struct { + JobType JobType + Entity *git.RepoEntity +} + +// JobType is the a git operation supported +type JobType string + +const ( + // Fetch is wrapper of git fetch command + Fetch JobType = "fetch" + // Pull is wrapper of git pull command + Pull JobType = "pull" + // Merge is wrapper of git merge command + Merge JobType = "merge" +) + +// starts the job +func (job *Job) start() error { + job.Entity.State = git.Working + // added for testing, TODO: remove + time.Sleep(time.Second) + // TODO: Handle errors? + switch mode := job.JobType; mode { + case Fetch: + if err := git.Fetch(job.Entity, git.FetchOptions{ + RemoteName: job.Entity.Remote.Name, + }); err != nil { + job.Entity.State = git.Fail + return nil + } + case Pull: + if err := git.Fetch(job.Entity, git.FetchOptions{ + RemoteName: job.Entity.Remote.Name, + }); err != nil { + job.Entity.State = git.Fail + return nil + } + if err := git.Merge(job.Entity, git.MergeOptions{ + BranchName: job.Entity.Remote.Branch.Name, + }); err != nil { + job.Entity.State = git.Fail + return nil + } + case Merge: + if err := git.Merge(job.Entity, git.MergeOptions{ + BranchName: job.Entity.Remote.Branch.Name, + }); err != nil { + job.Entity.State = git.Fail + return nil + } + default: + job.Entity.State = git.Available + return nil + } + job.Entity.State = git.Success + job.Entity.Refresh() + return nil +} diff --git a/pkg/queue/queue.go b/pkg/queue/queue.go index 871a380..93626f0 100644 --- a/pkg/queue/queue.go +++ b/pkg/queue/queue.go @@ -2,76 +2,15 @@ package queue import ( "errors" - "fmt" - "time" "github.com/isacikgoz/gitbatch/pkg/git" ) -// Job relates the type of the operation and the entity -type Job struct { - JobType JobType - Entity *git.RepoEntity -} - // JobQueue holds the slice of Jobs type JobQueue struct { series []*Job } -// JobType is the a git operation supported -type JobType string - -const ( - // Fetch is wrapper of git fetch command - Fetch JobType = "fetch" - // Pull is wrapper of git pull command - Pull JobType = "pull" - // Merge is wrapper of git merge command - Merge JobType = "merge" -) - -// CreateJob es its name implies creates a job struct and return its pointer -func CreateJob() (j *Job, err error) { - fmt.Println("Job created.") - return j, nil -} - -// starts the job -func (job *Job) start() error { - job.Entity.State = git.Working - // added for testing, TODO: remove - time.Sleep(time.Second) - // TODO: Handle errors? - switch mode := job.JobType; mode { - case Fetch: - if err := job.Entity.Fetch(); err != nil { - job.Entity.State = git.Fail - return nil - } - job.Entity.RefreshPushPull() - job.Entity.State = git.Success - case Pull: - if err := job.Entity.Pull(); err != nil { - job.Entity.State = git.Fail - return nil - } - job.Entity.RefreshPushPull() - job.Entity.State = git.Success - case Merge: - if err := job.Entity.Merge(); err != nil { - job.Entity.State = git.Fail - return nil - } - job.Entity.RefreshPushPull() - job.Entity.State = git.Success - default: - job.Entity.State = git.Available - return nil - } - return nil -} - // CreateJobQueue creates a jobqueue struct and initialize its slice then return // its pointer func CreateJobQueue() (jobQueue *JobQueue) { |
