Repositories

Modified README.md

@@ -88,7 +88,7 @@ clear that these are meant to be read and written by automated tools.
When a field named "v" appears in one of these notes, it is used to denote
the version of the metadata format being used. If that field is missing, then
it defaults to the value 0, which corresponds to this initial verison of the
it defaults to the value 0, which corresponds to this initial version of the
formats.
### Code Review Requests

Modified commands/comment.go

@@ -43,6 +43,9 @@ func commentOnReview(repo repository.Repo, args []string) error {
if *commentLgtm && *commentNmw {
return errors.New("You cannot combine the flags -lgtm and -nmw.")
}
if !*commentLgtm && !*commentNmw && *commentMessage == "" {
return errors.New("Message cannot be empty if neither the -lgtm or -nmw flag has been set.")
}
if *commentLine != 0 && *commentFile == "" {
return errors.New("Specifying a line number with the -l flag requires that you also specify a file name with the -f flag.")
}

Modified commands/show.go

@@ -27,7 +27,7 @@ import (
)
var showFlagSet = flag.NewFlagSet("show", flag.ExitOnError)
var showJsonOutput = showFlagSet.Bool("json", false, "Format the output as JSON")
var showJSONOutput = showFlagSet.Bool("json", false, "Format the output as JSON")
var showDiffOutput = showFlagSet.Bool("diff", false, "Show the current diff for the review")
var showDiffOptions = showFlagSet.String("diff-opts", "", "Options to pass to the diff tool; can only be used with the --diff option")
@@ -57,7 +57,7 @@ func showReview(repo repository.Repo, args []string) error {
if r == nil {
return errors.New("There is no matching review.")
}
if *showJsonOutput {
if *showJSONOutput {
return output.PrintJson(r)
}
if *showDiffOutput {

Modified commands/submit.go

@@ -37,17 +37,32 @@ var (
// The "args" parameter contains all of the command line arguments that followed the subcommand.
func submitReview(repo repository.Repo, args []string) error {
submitFlagSet.Parse(args)
args = submitFlagSet.Args()
if *submitMerge && *submitRebase {
return errors.New("Only one of --merge or --rebase is allowed.")
}
r, err := review.GetCurrent(repo)
var r *review.Review
var err error
if len(args) > 1 {
return errors.New("Only accepting a single review is supported.")
}
if len(args) == 1 {
r, err = review.Get(repo, args[0])
} else {
r, err = review.GetCurrent(repo)
}
if err != nil {
return err
return fmt.Errorf("Failed to load the review: %v\n", err)
}
if r == nil {
return errors.New("There is nothing to submit")
return errors.New("There is no matching review.")
}
if r.Submitted {
return errors.New("The review has already been submitted.")
}
if !*submitTBR && (r.Resolved == nil || !*r.Resolved) {
@@ -55,11 +70,11 @@ func submitReview(repo repository.Repo, args []string) error {
}
target := r.Request.TargetRef
source := r.Request.ReviewRef
if err := repo.VerifyGitRef(target); err != nil {
return err
}
if err := repo.VerifyGitRef(source); err != nil {
source, err := r.GetHeadCommit()
if err != nil {
return err
}

Modified repository/mock_repo.go

@@ -162,11 +162,11 @@ func (r mockRepoForTest) GetPath() string { return "~/mockRepo/" }
// GetRepoStateHash returns a hash which embodies the entire current state of a repository.
func (r mockRepoForTest) GetRepoStateHash() (string, error) {
repoJson, err := json.Marshal(r)
repoJSON, err := json.Marshal(r)
if err != nil {
return "", err
}
return fmt.Sprintf("%x", sha1.Sum([]byte(repoJson))), nil
return fmt.Sprintf("%x", sha1.Sum([]byte(repoJSON))), nil
}
// GetUserEmail returns the email address that the user has used to configure git.

Modified repository/repo.go

@@ -20,6 +20,7 @@ package repository
// Note represents the contents of a git-note
type Note []byte
// CommitDetails represents the contents of a commit.
type CommitDetails struct {
Author string `json:"author,omitempty"`
AuthorEmail string `json:"authorEmail,omitempty"`