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

✨ Add commit depth support for GitLab #3672

Merged
merged 4 commits into from
Nov 15, 2023

Conversation

ashearin
Copy link
Contributor

@ashearin ashearin commented Nov 13, 2023

What kind of change does this PR introduce?

Bug fix for #2828, reopening of #2829

What is the current behavior?

The new gitlab functionality is not using the parameter --commit-depth in querying the gitlab repo for commits. In addition the defaulted value of 30 was not being used either, for the same reason.

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

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Fixes #2828

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.)

Added `--commit-depth` support for GitLab repos

…epth value provided

Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
@ashearin ashearin requested a review from a team as a code owner November 13, 2023 17:55
@ashearin ashearin requested review from spencerschrock and raghavkaul and removed request for a team November 13, 2023 17:55
@ashearin ashearin changed the title feat: Integrated paging to allow for querying based on the --commit-d… 🌱 Commit depth for GitLab Nov 13, 2023
clients/gitlabrepo/commits.go Show resolved Hide resolved
clients/gitlabrepo/commits.go Outdated Show resolved Hide resolved
clients/gitlabrepo/commits.go Outdated Show resolved Hide resolved
Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Merging #3672 (e7545c0) into main (a4ee314) will decrease coverage by 5.56%.
The diff coverage is 96.15%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3672      +/-   ##
==========================================
- Coverage   76.09%   70.54%   -5.56%     
==========================================
  Files         205      205              
  Lines       14027    14042      +15     
==========================================
- Hits        10674     9906     -768     
- Misses       2722     3563     +841     
+ Partials      631      573      -58     

@spencerschrock spencerschrock changed the title 🌱 Commit depth for GitLab ✨ Add commit depth support for GitLab Nov 14, 2023
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.

Looks good overall. Thanks for the small + tested PR.

I left one comment about an easy test I'd like to see before merge.

There's also a harder test for pagination, but I'm fine merging without it. Our existing suffixStubTripper isn't good enough, since some of the values go-gitlab cares about are in the header, not the response.

curl -vvv --header "PRIVATE-TOKEN: $GITLAB_AUTH_TOKEN" "https://gitlab.com/api/v4/projects/10858056/repository/commits?page=1&per_page=101"
...
< x-next-page: 2
< x-page: 1
< x-per-page: 100
< x-prev-page: 
...

But testing it manually seemed to work for something like:

go run main.go --repo https://gitlab.com/baserow/baserow --checks Maintained --commit-depth 101 --format json --show-details | jq
{
  "date": "2023-11-14T16:01:37-08:00",
  "repo": {
    "name": "gitlab.com/baserow/baserow",
    "commit": "f12615ea0419d0840626ce152f25f6981e93c081"
  },
  "scorecard": {
    "version": "",
    "commit": "unknown"
  },
  "score": 10,
  "checks": [
    {
      "details": null,
      "score": 10,
      "reason": "101 commit(s) out of 101 and 20 issue activity out of 20 found in the last 90 days -- score normalized to 10",
      "name": "Maintained",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained",
        "short": "Determines if the project is \"actively maintained\"."
      }
    }
  ],
  "metadata": null
}

clients/gitlabrepo/commits.go Show resolved Hide resolved
ashearin and others added 2 commits November 14, 2023 18:50
Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
@spencerschrock spencerschrock enabled auto-merge (squash) November 15, 2023 03:15
@spencerschrock spencerschrock merged commit 14f864b into ossf:main Nov 15, 2023
38 checks passed
@ashearin ashearin deleted the commit-depth branch November 16, 2023 21:01
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.

BUG: Commit-Depth Not Used on Querying Gitlab
2 participants