func auditStepModelBeforeSharePullRequest(step models.StepModel, stepID, version string) error { if err := step.Audit(); err != nil { return fmt.Errorf("Failed to audit step infos, error: %s", err) } pth, err := pathutil.NormalizedOSTempDirPath(stepID + version) if err != nil { return fmt.Errorf("Failed to create a temporary directory for the step's audit, error: %s", err) } if step.Source == nil { return fmt.Errorf("Missing Source porperty") } err = retry.Times(2).Wait(3 * time.Second).Try(func(attempt uint) error { return cmdex.GitCloneTag(step.Source.Git, pth, version) }) if err != nil { return fmt.Errorf("Failed to git-clone the step (url: %s) version (%s), error: %s", step.Source.Git, version, err) } latestCommit, err := cmdex.GitGetLatestCommitHashOnHead(pth) if err != nil { return fmt.Errorf("Failed to get git-latest-commit-hash, error: %s", err) } if latestCommit != step.Source.Commit { return fmt.Errorf("Step commit hash (%s) should be the latest commit hash (%s) on git tag", step.Source.Commit, latestCommit) } return nil }
func auditStepModelBeforeSharePullRequest(step models.StepModel, stepID, version string) error { if err := step.Audit(); err != nil { return err } pth, err := pathutil.NormalizedOSTempDirPath(stepID + version) if err != nil { return err } if err := cmdex.GitCloneTag(step.Source.Git, pth, version); err != nil { return err } latestCommit, err := cmdex.GitGetLatestCommitHashOnHead(pth) if err != nil { return err } if latestCommit != step.Source.Commit { return fmt.Errorf("Step commit hash (%s) should be the latest commit hash (%s) on git tag", step.Source.Commit, latestCommit) } return nil }