Esempio n. 1
0
// 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
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
// 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
}
Esempio n. 4
0
// 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
}
Esempio n. 5
0
// 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
}