Skip to content

Conversation

@amascia-gg
Copy link

The base_revision has many issues and can't be relied on to get the commit range.
The proposed solution is to fetch the number of commits included in the push event in order to list the commits to scan.

src/@orb.yml Outdated
environment:
CIRCLE_RANGE: <<parameters.base_revision>>...<<parameters.revision>>
NUMBER_COMMITS_GH: <<parameters.number_commits_gh>>
NUMBER_COMMITS_GL: <<parameters.number_commits_gl>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would have been nice to expose only one variable, but I assume it's not possible to do operations like max or + here?

Copy link
Author

Choose a reason for hiding this comment

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

It seems possible if I do something like

GITHUB_COUNT="<<pipeline.trigger_parameters.github_app.total_commits_count>>"
GITLAB_COUNT="<<pipeline.trigger_parameters.gitlab.total_commits_count>>"
MAX_COUNT=$(( GITHUB_COUNT > GITLAB_COUNT ? GITHUB_COUNT : GITLAB_COUNT ))
echo "export CIRCLE_COMMIT_COUNT=$MAX_COUNT" >> $BASH_ENV

In run, before the ggshield secret scan command

Do you think it's worth it ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit hackish, but that is what happens with shell scripting :). I think it's worth it because it means we don't have to make a new ggshield release if we ever find a way to get the BitBucket count, or whatever ci-host-of-the-day is added to CircleCI in the future.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @agateau-gg, I am tackling this issue since I have some time now but I am really struggling to make this work.
I've tried a lot of solutions (you can see them in the commits of this branch) but I can't find a way to fetch both values (for GitHub and GitLab). Can we have a look together if you have some time please?

@amascia-gg amascia-gg force-pushed the amascia/get-number-of-commits branch from 0f1b407 to 75350f6 Compare October 12, 2023 15:12
@amascia-gg amascia-gg force-pushed the amascia/get-number-of-commits branch from 75350f6 to d4812a6 Compare November 13, 2023 17:33
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.

2 participants