summaryrefslogtreecommitdiff
path: root/pkg/queue/queue.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/queue/queue.go')
-rw-r--r--pkg/queue/queue.go61
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) {