예제 #1
0
파일: task.go 프로젝트: TechMantra/focus
// Start runs the start scripts
func (t *Task) Start(args TaskArgs, reply *[]string) error {
	log.Println("Start working on task.")
	gitClient := g.NewGitClient(args.Path)
	currentBranch, err := gitClient.CurrentBranch()
	if err != nil {
		return err
	}
	if currentBranch != "master" {
		if err := gitClient.Checkout("master"); err != nil {
			log.Println("Already on master", err)
		}
	}

	// TODO - should maybe do a quick git pull
	if gitClient.BranchExists("focus/github/" + args.ID) {
		gitClient.Checkout("focus/github/" + args.ID)
	} else {
		gitClient.CheckoutNewBranch("focus/github/" + args.ID)
		err = gitClient.Commit("Fixes #"+args.ID, true)
		if err != nil {
			return err
		}
	}
	// TODO - Start change watcher that will commit
	return nil
}
예제 #2
0
파일: task.go 프로젝트: TechMantra/focus
// Log lets the user log progress on a task
func (t *Task) Log(args TaskArgs, reply *[]string) error {
	gitClient := g.NewGitClient(args.Path)
	currentFocus, err := getCurrentFocus(gitClient)
	log.Println("ID", currentFocus, err)
	if err != nil {
		return err
	}
	commitMsg, err := gitClient.LastCommitMsg()
	if err != nil {
		return err
	}

	file, err := ioutil.TempFile(os.TempDir(), "focus")
	if commitMsg == "" {
		fmt.Fprintf(file, "\nFixes #%s", currentFocus)
	} else {
		log.Println("Got commit message")
		fmt.Fprint(file, commitMsg)
	}

	log.Println("Last commit message: ", commitMsg)

	err = runEditor([]string{"-w", file.Name()})
	logFile, err := readLog(file.Name())

	store.Set(s.LogBucket, "github"+currentFocus, logFile)
	err = gitClient.Commit(string(logFile), true)
	if err != nil {
		return err
	}

	os.Remove(file.Name())
	return err
}
예제 #3
0
파일: task.go 프로젝트: TechMantra/focus
// Status return the current task being focused on
func (t *Task) Status(args TaskArgs, reply *[]string) error {
	gitClient := g.NewGitClient(args.Path)
	currentFocus, err := getCurrentFocus(gitClient)
	if err != nil {
		return err
	}
	*reply = append(*reply, currentFocus)
	status, err := gitClient.Status(true)
	if err != nil {
		return err
	}
	*reply = append(*reply, string(status))

	return nil
}
예제 #4
0
파일: task.go 프로젝트: TechMantra/focus
// Stop stops the work on a given task
func (t *Task) Stop(args TaskArgs, reply *[]string) error {
	// TODO: Stop change watcher
	log.Println("Task Stop")
	gitClient := g.NewGitClient(args.Path)
	currentBranch, err := gitClient.CurrentBranch()
	if err != nil {
		return err
	}
	if currentBranch != "master" {
		if err := gitClient.Checkout("master"); err != nil {
			log.Println("Already on master", err)
		}
	}
	// TODO: push or other tasks
	return nil
}
예제 #5
0
파일: task.go 프로젝트: TechMantra/focus
// Done closes the task and publishes it
func (t *Task) Done(args TaskArgs, reply *[]string) error {
	log.Println("Done")
	gitClient := g.NewGitClient(args.Path)
	currentFocus, err := getCurrentFocus(gitClient)
	if err != nil {
		return err
	}

	// TODO: Final git commit
	var message []byte
	store.Get(s.LogBucket, "github"+currentFocus, &message)

	err = gitClient.AddRemove()
	err = gitClient.Commit(string(message), true)
	if err != nil {
		return err
	}
	// TODO: delete the branch
	if err := gitClient.Checkout("master"); err != nil {
		return err
	}
	return nil
}