示例#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
}