Esempio n. 1
0
func handleCommit(ctx *cli.Context, client *daemon.Client) error {
	message := ctx.String("message")
	if message == "" {
		message = fmt.Sprintf("Update on %s", time.Now().String())
	}
	status, err := client.Status()
	if err != nil {
		return err
	}

	statusCmt := status.Commit
	if statusCmt == nil {
		return fmt.Errorf("Empty status commit in response.")
	}

	commitCnt := len(statusCmt.Changeset)
	if commitCnt == 0 {
		fmt.Println("Nothing to commit.")
		return nil
	}
	if commitCnt != 1 {
		fmt.Printf("%d changes commited.\n", commitCnt)
	} else {
		fmt.Printf("%d change commited.\n", commitCnt)
	}

	return client.MakeCommit(message)
}