A read-only clone of the dehub project, for until dehub.dev can be brought back online.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dehub/cmd/dehub/cmd_verify.go

40 lines
1.1 KiB

package main
import (
"context"
"dehub/cmd/dehub/dcmd"
"fmt"
"gopkg.in/src-d/go-git.v4/plumbing"
)
func cmdVerify(ctx context.Context, cmd *dcmd.Cmd) {
flag := cmd.FlagSet()
rev := flag.String("rev", "HEAD", "Revision of commit to verify")
branch := flag.String("branch", "", "Branch that the revision is on. If not given then the currently checked out branch is assumed")
cmd.Run(func() (context.Context, error) {
repo := ctxRepo(ctx)
h, err := repo.GitRepo.ResolveRevision(plumbing.Revision(*rev))
if err != nil {
return nil, fmt.Errorf("could not resolve revision %q: %w", *rev, err)
}
var branchName plumbing.ReferenceName
if *branch == "" {
if branchName, err = repo.CheckedOutBranch(); err != nil {
return nil, fmt.Errorf("could not determined currently checked out branch: %w", err)
}
} else {
branchName = plumbing.NewBranchReferenceName(*branch)
}
if err := repo.VerifyCommit(branchName, *h); err != nil {
return nil, fmt.Errorf("could not verify commit at %q (%s): %w", *rev, *h, err)
}
fmt.Printf("commit at %q (%s) is good to go!\n", *rev, *h)
return nil, nil
})
}