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

🌱 differentiate between refs and sha gitab #3729

Merged
merged 5 commits into from
Dec 18, 2023

Conversation

ashearin
Copy link
Contributor

What kind of change does this PR introduce?

Adds a check to listCheckRunsForRef in the Gitlab Handler to differentiate between shas and branches/tags and makes appropriate changes to the gitlab api call based on that check.

What is the current behavior?

listCheckRunsForRef in the GItlab Handler takes in a ref string, but assumes that the ref is a sha when making the gitlab api call. Gitlab API sometimes handles refs as a branch or tag name, while sha refers to a commit hash. If in the future we passed in a branch or tag to listCheckRunsForRef the API would fail since we would handle it as a sha.

What is the new behavior (if this is a feature change)?**

Added a check to compare the passed in ref string against a regex matching a SHA value. If there is a match we handle the ref as a SHA, otherwise we handle it as a ref (branch/tag)

  • Tests for the changes have been updated

Which issue(s) this PR fixes

Fixes #3395

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)


@ashearin ashearin requested a review from a team as a code owner December 12, 2023 18:48
@ashearin ashearin requested review from spencerschrock and laurentsimon and removed request for a team December 12, 2023 18:48
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Merging #3729 (7ba5108) into main (f4bf574) will decrease coverage by 6.17%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3729      +/-   ##
==========================================
- Coverage   74.97%   68.80%   -6.17%     
==========================================
  Files         216      216              
  Lines       14963    14966       +3     
==========================================
- Hits        11219    10298     -921     
- Misses       3080     4053     +973     
+ Partials      664      615      -49     

Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Thanks, left a few small comments

clients/gitlabrepo/checkruns.go Outdated Show resolved Hide resolved
clients/gitlabrepo/checkruns.go Outdated Show resolved Hide resolved
clients/gitlabrepo/checkruns.go Outdated Show resolved Hide resolved
Signed-off-by: Allen Shearin <[email protected]>
Signed-off-by: Allen Shearin <[email protected]>
@spencerschrock spencerschrock enabled auto-merge (squash) December 18, 2023 20:44
@spencerschrock spencerschrock merged commit df7d888 into ossf:main Dec 18, 2023
38 checks passed
@ashearin ashearin deleted the gitlab-sha-vs-ref branch January 3, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Difference between GitLab refs and GitHub refs
3 participants