Comments (15)
I'm really interested in this. What would be the best way to implement it?
I've been checking the github::calculate_total_modifications() method and the Github API docs and the only approach I found would be:
- Allow a 8th argument to be passed to the action (ignore_files), which would be a string with the comma-separated files to ignore.
- Inside calculate_total_modifications() define a variable totalLines = deteledLines + addedLines (current returned value)
- Loop over every file in the PR (using this endpoint GET /repos/:owner/:repo/pulls/:pull_number/files) and check if the filename matches one of the ignored_files. If it does, substract its (deletedLines + addedLines) from the totalLines.
Does this make sense? Am I missing anything?
from pr-size-labeler.
Thanks this project.
is there anything working on this issue?
If nobody solving it, I will contribute to solve this issue .
from pr-size-labeler.
from pr-size-labeler.
Dear @kevindice @dowrow @JavierCane et al.
I've been using the pr-size-labeler workflow for quite a while now (it's simple yet super helpful!), so I gave this issue a try: Have a look at this one commit from my forked repo: favmd@992a73a
The code basically does what has been described above:
- Allow a whitespace(!)-separated list of files to be ignored (
files_to_ignore
) - If
files_to_ignore
is empty, the old code will be used (see below for the rationale behind this!) - If
files_to_ignore
is given, it will loop through the list of files and count thechanges
Plus: Minor modifications:
- Add missing
message_if_xl
parameter description to README.md - Fix issue #29
Note however that my code does have its LIMITATIONS and should be tested by someone else too:
- Filenames with whitespaces are not supported (never saw that in auto-generated filenames anyway...)
files_to_ignore
is global (as described above), i.e., filenames will be ignored in every part of the repo- Only the first 100 files are taken into account
â (note that the Pulls API endpoint GET /repos/{owner}/{repo}/pulls/{pull_number}/files is paginated and limited to 3000 files max (100 files max per page))
I can live with that limitation due to the fact that we don't open PRs with hundreds of changed files, but this is the reason why my code will fall back to the old code if files_to_ignore
is empty: to ensure that someone not using the new parameter does not have this limitation at all and falls back to the API endpoint without /files
at the end.
P.S. Dear @magnattic: Your approach did not work for me, but maybe I just missed some little detail.
from pr-size-labeler.
It would be awesome to support this
@dowrow, your approach seems to completely make sense đ
The only thing I would suggest would be using a YAML sequence instead of a comma separated string for specifying the different files to ignore. That is, being able to specify it as files_to_ignore: ['package-lock.json', 'composer.lock']
instead of files_to_ignore: 'package-lock.json, composer.lock'
.
Example of how the README.md
complete example would look like:
name: labeler
on: [pull_request]
jobs:
labeler:
runs-on: ubuntu-latest
name: Label the PR size
steps:
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_max_size: '10'
s_max_size: '100'
m_max_size: '500'
l_max_size: '1000'
fail_if_xl: 'false'
message_if_xl: 'This PR is so big! Please, split it đ'
files_to_ignore: ['package-lock.json', 'composer.lock']
What do you think?
from pr-size-labeler.
Hey @ddalpange, that would be great! I can't really move forward with this issue at the moment.
from pr-size-labeler.
@rgomezcasas @dowrow what about this commit? Seems like it does what is being described here: martincleto@7fc2823
from pr-size-labeler.
@mrchief does it? It looks like it adds the argument, but doesn't actually use it
from pr-size-labeler.
@mharris717 you're right - seems like it goes all the way except ignoring actual changes.
from pr-size-labeler.
Wouldn't the correct solution be to mark those files in the .gitattributes
file so they count towards the lines changed in Github?
I haven't tested this yet myself but that seems to be exactly what the linguist-generated
flag is for:
https://github.com/github/linguist/blob/master/docs/overrides.md#generated-code
So for the example given just add a .gitattributes
file with
package-lock.json linguist-generated=true
to your repo and hopefully those line changes are then ignored in the labeller as well?
from pr-size-labeler.
@favmd You are right, after testing this myself I think the approach does not work as expected, unfortunately. The lines are still counted by github even if the file is marked as linguist-generated=true
.
Maybe that's also an issue we could raise with github, I feel like those should be excluded from the diff altogether.
EDIT:
from pr-size-labeler.
Regarding this feature request: It would be awesome if files_to_ignore
would support glob patterns, so the syntax would be in line with e.g. .gitignore
.
from pr-size-labeler.
Dear @magnattic Upvoted your discussion! Let's see where this leads.
You are right: From the docs I would have expected your approach to work just fine.
Regarding this feature request: It would be awesome if
files_to_ignore
would support glob patterns, so the syntax would be in line with e.g..gitignore
.
That's way more than I need, but a wonderful idea (maybe for another Issue/PR if this one gets approved?).
Feel free to fork and improve my approach :)
from pr-size-labeler.
@favmd nice, thanks for working on that. this seems ready for review, could you open a pull request? not sure if the repo maintainers will see it otherwise.
from pr-size-labeler.
Feature implemented thanks to @favmd đ
You can see how to use it in the documentation.
Thanks!
from pr-size-labeler.
Related Issues (20)
- Liveness probe of repo HOT 4
- Size Label Customization
- Github API url is not necessary HOT 3
- [code style] $1 is used instead of named parameter
- Please consider NGS HOT 2
- Ability to set label color HOT 1
- Duplicated labels when PR is updated HOT 1
- Subtle bug đĨ in support for ignoring files !? HOT 7
- Ignore files and folders by pattern? HOT 7
- Not working anymore HOT 11
- PR size labeler is not working HOT 2
- Is it possible to make github bot as labeler? HOT 2
- Label is not added pull requests HOT 1
- Feature Request: Regular expression support for files_to_ignore parameter HOT 5
- Document required permissions HOT 5
- XL warning message is posted repeatedly HOT 2
- Allow messages per size definition
- A new release with regex support HOT 3
- Possible to not pass message_if_xl? HOT 2
- Add support to ignore whitespace-only changes? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pr-size-labeler.