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

fix: err if sha dont match #5

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions server/events/vcs/gitlab_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ func (g *GitlabClient) UpdateStatus(logger logging.SimpleLogging, repo models.Re
return err
}
if mr.HeadPipeline != nil {
logger.Info("Head pipeline found for merge request %d, source '%s'. pipelineID '%s'",
logger.Info("Head pipeline found for merge request %d, source '%s'. pipelineID '%d'",
pull.Num, mr.HeadPipeline.Source, mr.HeadPipeline.ID)
pipelineID = gitlab.Ptr(mr.HeadPipeline.ID)

// let's check to see if the pipeline sha matches the head commit.
// if these don't match then there has been a new commit so let's return
if mr.HeadPipeline.SHA != pull.HeadCommit {
logger.Err("Head pipeline SHA does not match pull head commit")
return errors.Errorf("mr.HeadPipeline.SHA: '%s' does not match pull.HeadCommit '%s'", mr.HeadPipeline.SHA, pull.HeadCommit)
}
break
}
Expand Down
4 changes: 2 additions & 2 deletions server/events/vcs/gitlab_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestGitlabClient_UpdateStatus(t *testing.T) {
testServer := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.RequestURI {
case "/api/v4/projects/runatlantis%2Fatlantis/statuses/sha":
case "/api/v4/projects/runatlantis%2Fatlantis/statuses/67cb91d3f6198189f433c045154a885784ba6977":
gotRequest = true

body, err := io.ReadAll(r.Body)
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestGitlabClient_UpdateStatus(t *testing.T) {
models.PullRequest{
Num: 1,
BaseRepo: repo,
HeadCommit: "sha",
HeadCommit: "67cb91d3f6198189f433c045154a885784ba6977",
HeadBranch: "test",
}, c.status, "src", "description", "https://google.com")
Ok(t, err)
Expand Down
Loading