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

[Feature] Enhance visibility of security tag pull request titles #53

Closed
apoclyps opened this issue Apr 27, 2021 · 5 comments · Fixed by #93
Closed

[Feature] Enhance visibility of security tag pull request titles #53

apoclyps opened this issue Apr 27, 2021 · 5 comments · Fixed by #93
Labels
enhancement New feature or request good first issue Good for newcomers python Pull requests that update Python code
Projects

Comments

@apoclyps
Copy link
Owner

apoclyps commented Apr 27, 2021

Is your feature request related to a problem? Please describe.
I would like to highlight [Security] updates in yellow to identify them uniquely within a list of pull requests

Describe the solution you'd like
I would like the pull request title to highlight [Security] in yellow, whilst the rest of the text remains white.

Additional context

You can find a project with security updates required at apoclyps/home_automation

export REPOSITORY_CONFIGURATION="apoclyps/dexi,apoclyps/my-dev-space,apoclyps/home_automation"
reviews dashboard

This will produce results similar to the following

image

Implementation Notes

The colour is currently set to "[white]" by adding this string as a prefix to the pull request title in

for pr in pull_requests:
approved = "[green]Approved" if pr.approved else ""
updated_at = humanize.naturaltime(pr.updated_at)
colour = ""
if (datetime.now() - pr.updated_at).days >= 7:
colour = "[red]"
elif (datetime.now() - pr.updated_at).days >= 1:
colour = "[yellow]"
updated_at = f"{colour}{updated_at}"
labels = ", ".join([label.name for label in pr.labels])
table.add_row(
f"[white]{pr.number} ",
f"[white]{pr.title}",
f"{labels}",
f"{updated_at}",
f"{approved}",
)

The Rich library has support for applying additional formatting to a line of text.

See: https://github.com/willmcgugan/rich/blob/e34eadb3a9354c2469fa2112400ce2690f2663ba/rich/__main__.py#L103-L106 which shows the markup section from https://raw.githubusercontent.com/willmcgugan/rich/master/imgs/features.png

@apoclyps apoclyps added enhancement New feature or request good first issue Good for newcomers python Pull requests that update Python code labels Apr 27, 2021
@carrickkv2
Copy link

I'll look into this.

@yushao2
Copy link
Contributor

yushao2 commented May 8, 2021

take

@yushao2
Copy link
Contributor

yushao2 commented May 8, 2021

After thinking on this for a bit more, would it make sense to instead implement a feature whereby a user can configure custom colours for specific labels?

This becomes a non-trivial problem but would definitely allow for more flexibility -- especially if [Security] is not a common label used by devs through all projects/repos -- just my two cents.

And of course I might be wrong here as I am not too exposed to many projects

@apoclyps apoclyps changed the title [Feature] Enhance visibility of security pull requests [Feature] Enhance visibility of security tag pull request titles May 8, 2021
@apoclyps
Copy link
Owner Author

apoclyps commented May 8, 2021

@yushao2 I like your idea and my preference is to allow for configurable colours based on user-defined labels. As labels are very custom and it's hard to limit this to a specific subset.

You can find a feature request to colourise the labels in #85 which aligns with the changes to the Labels section; we should include your suggested change in the scope of that feature request and we can discuss it further if you have any thoughts or concerns around how we might implement it.

As for this feature request, it's limited to the Security tag that is prefixed to pull requests title in a pull request. This is a known standard set for security pull requests by placing Security in the title when raised by Github/Dependabot so there shouldn't be any variants to support.

@yushao2
Copy link
Contributor

yushao2 commented May 8, 2021

@yushao2 I like your idea and my preference is to allow for configurable colours based on user-defined labels. As labels are very custom and it's hard to limit this to a specific subset.

You can find a feature request to colourise the labels in #85 which aligns with the changes to the Labels section; we should include your suggested change in the scope of that feature request and we can discuss it further if you have any thoughts or concerns around how we might implement it.

As for this feature request, it's limited to the Security tag that is prefixed to pull requests title in a pull request. This is a known standard set for security pull requests by placing Security in the title when raised by Github/Dependabot so there shouldn't be any variants to support.

Ah, okay. My bad on this -- I thought it was to be for Security labels. I'll take this up and give it a shot.

Thanks

0.2.0 automation moved this from To do to Release Candidate May 8, 2021
@apoclyps apoclyps moved this from Release Candidate to Done in 0.2.0 May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers python Pull requests that update Python code
Projects
No open projects
0.2.0
Done
Development

Successfully merging a pull request may close this issue.

3 participants