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

feat: validate commit SHAs #231

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Conversation

giovanni-guidini
Copy link
Contributor

This was motivated by the fact that api returns 404 if your label-analysis request
doesn't include a base_commit or a head_commit. I don't mean the key must be there,
the value needs to be an accurate value, or it will return a puzzling 404 "Not Found".

That is terrible user experience, and even I needed quite some time to figure it out.
So the best thing (I think) is cutting the evil in its root and making sure the user
gives us a valid SHA.

These changes introduce validate_commit_sha to static-analysis and label-analysis commands.
They make sure the user gives us a string that is 40 chars long and consists of only letters and
numbers. So should at least look like a SHA1 string.

This was motivated by the fact that api returns 404 if your label-analysis request
doesn't include a `base_commit` or a `head_commit`. I don't mean the key must be there,
the value needs to be an accurate value, or it will return a puzzling 404 "Not Found".

That is terrible user experience, and even I needed quite some time to figure it out.
So the best thing (I think) is cutting the evil in its root and making sure the user
gives us a valid SHA.

These changes introduce `validate_commit_sha` to `static-analysis` and `label-analysis` commands.
They make sure the user gives us a string that is 40 chars long and consists of only letters and
numbers. So should at least look like a SHA1 string.
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #231 (c9ea791) into master (f577035) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #231      +/-   ##
==========================================
+ Coverage   95.18%   95.20%   +0.02%     
==========================================
  Files          73       74       +1     
  Lines        2573     2585      +12     
==========================================
+ Hits         2449     2461      +12     
  Misses        124      124              
Flag Coverage Δ
python3.10 95.20% <100.00%> (+0.02%) ⬆️
python3.7 95.19% <100.00%> (+0.02%) ⬆️
python3.8 95.20% <100.00%> (+0.02%) ⬆️
python3.9 95.20% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
codecov_cli/commands/labelanalysis.py 95.96% <100.00%> (+0.03%) ⬆️
codecov_cli/commands/staticanalysis.py 86.36% <100.00%> (+0.64%) ⬆️
codecov_cli/helpers/validators.py 100.00% <100.00%> (ø)

@giovanni-guidini giovanni-guidini merged commit e6726bb into master Aug 14, 2023
10 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/validate-commit-shas branch August 14, 2023 12:28
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