Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look at the current reviewRef when submitting #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func submitReview(repo repository.Repo, args []string) error {
if err := repo.VerifyGitRef(target); err != nil {
return err
}
source, err := r.GetHeadCommit()
if err != nil {
source := r.Request.ReviewRef
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want to use the result of GetHeadCommit in the below check. It will actually use the review ref head if the metadata linking the review commit to the review ref head is properly set up.

However, we also want to give the user instructions on how to fix it if that metadata is not correct.

I think a better fix might be to add logic right after this (right before we check the ancestry of the target ref) to double check that the metadata is correct and give the user instructions on how to fix it if it is not.

Something like:

	isReviewAssociatedWithRef, err := repo.IsAncestor(source, r.Request.ReviewRef)
	if err != nil {
		return err
	}
	if !isReviewAssociatedWithRef {
		return fmt.Errorf("The review commit is not associated with the review ref %q. If the change has been rebased, then reassociate the review commit with the review ref using the command `git appraise rebase %s`", r.Request.ReviewRef, r.Revision)
	}

if err := repo.VerifyGitRef(source); err != nil {
return err
}

Expand Down