diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-07 01:16:37 +0300 |
|---|---|---|
| committer | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-07 01:16:37 +0300 |
| commit | f2fda8bb82e157a87d81f438b030790fb0b4c802 (patch) | |
| tree | 8993431916e8f5af11aeb37b09c71546f746fcb4 /pkg/queue/queue.go | |
| parent | not pushed commits highlighted in commits panel (diff) | |
| download | gitbatch-f2fda8bb82e157a87d81f438b030790fb0b4c802.tar.gz | |
git command handling partially migrated to new style
Diffstat (limited to 'pkg/queue/queue.go')
| -rw-r--r-- | pkg/queue/queue.go | 61 |
1 files changed, 0 insertions, 61 deletions
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) { |
