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: support commas in PipelineRun annotations #1825

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Nov 19, 2024

This commit introduces support for using commas within annotations by
allowing users to escape them with the HTML entity ,. This ensures
compatibility with annotations that rely on comma-separated values while
also permitting the inclusion of literal commas in file paths or branch
names.

This enhancement maintains backward compatibility while enabling more
precise and flexible use of annotations.

Jira: https://issues.redhat.com/browse/SRVKP-6790
Signed-off-by: Chmouel Boudjnah [email protected]

Submitter Checklist

  • 📝 Please ensure your commit message is clear and informative. For guidance on crafting effective commit messages, refer to the How to write a git commit message guide. We prefer the commit message to be included in the PR body itself rather than a link to an external website (ie: Jira ticket).

  • ♽ Before submitting a PR, run make test lint to avoid unnecessary CI processing. For an even more efficient workflow, consider installing pre-commit and running pre-commit install in the root of this repository.

  • ✨ We use linters to maintain clean and consistent code. Please ensure you've run make lint before submitting a PR. Some linters offer a --fix mode, which can be executed with the command make fix-linters (ensure markdownlint and golangci-lint tools are installed first).

  • 📖 If you're introducing a user-facing feature or changing existing behavior, please ensure it's properly documented.

  • 🧪 While 100% coverage isn't a requirement, we encourage unit tests for any code changes where possible.

  • 🎁 If feasible, please check if an end-to-end test can be added. See README for more details.

  • 🔎 If there's any flakiness in the CI tests, don't necessarily ignore it. It's better to address the issue before merging, or provide a valid reason to bypass it if fixing isn't possible (e.g., token rate limitations).

@chmouel
Copy link
Member Author

chmouel commented Nov 19, 2024

This needs to be merged after #1823

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.40%. Comparing base (3325ba7) to head (030cc8e).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1825      +/-   ##
==========================================
+ Coverage   65.38%   65.40%   +0.01%     
==========================================
  Files         177      177              
  Lines       13704    13706       +2     
==========================================
+ Hits         8961     8965       +4     
+ Misses       4141     4140       -1     
+ Partials      602      601       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chmouel chmouel force-pushed the SRVKP-6790-support-branch-with-commas branch from 6185ffd to 4878a24 Compare November 27, 2024 15:12
@chmouel
Copy link
Member Author

chmouel commented Nov 27, 2024

/test go-testing

docs/content/docs/guide/authoringprs.md Outdated Show resolved Hide resolved
This commit introduces support for using commas within annotations by
allowing users to escape them with the HTML entity `&openshift-pipelines#44;`. This ensures
compatibility with annotations that rely on comma-separated values while
also permitting the inclusion of literal commas in file paths or branch
names.

This enhancement maintains backward compatibility while enabling more
precise and flexible use of annotations.

**Jira**: https://issues.redhat.com/browse/SRVKP-6790
**Signed-off-by**: Chmouel Boudjnah <[email protected]>

Signed-off-by: Chmouel Boudjnah <[email protected]>
@chmouel chmouel force-pushed the SRVKP-6790-support-branch-with-commas branch from 4878a24 to 030cc8e Compare November 29, 2024 08:21
@@ -71,13 +71,15 @@ func getAnnotationValues(annotation string) ([]string, error) {

// if it's not an array then it would be a single string
if !strings.HasPrefix(annotation, "[") {
return []string{annotation}, nil
// replace &#44; with comma so users can have comma in the annotation
annot := strings.ReplaceAll(annotation, "&#44;", ",")
Copy link
Member

Choose a reason for hiding this comment

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

Will it replace when , is inbetween name such as [main, release,nightly]
OR
does its replace in this scenario as well [main, release]

Copy link
Member Author

Choose a reason for hiding this comment

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

strings.Split doesn't consider spaces... so [main, release,nightly] means any of those branches.

@chmouel chmouel merged commit a651604 into openshift-pipelines:main Dec 4, 2024
7 checks passed
@chmouel chmouel deleted the SRVKP-6790-support-branch-with-commas branch December 4, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants