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

Handle branch name with slash #1396

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Aug 29, 2023

We now allow users to specify a remote GitHub URL to be fetched using a token, even if the branch name contains a slash. The user can URL encoding the slash within the branch name to ensure a proper parsing by paac.

ie:

https://github.com/organization/repository/blob/feature%2Fmainbranch/path/file

Fixes #1395

Changes

Submitter Checklist

  • 📝 A good commit message is important for other reviewers to understand the context of your change. Please refer to How to Write a Git Commit Message for more details how to write beautiful commit messages. We rather have the commit message in the PR body and the commit message instead of an external website.
  • ♽ Run make test before submitting a PR (ie: with pre-commit, no need to waste CPU cycle on CI. (or even better install pre-commit and do pre-commit install in the root of this repo).
  • ✨ We heavily rely on linters to get our code clean and consistent, please ensure that you have run make lint before submitting a PR. The markdownlint error can get usually fixed by running make fix-markdownlint (make sure it's installed first)
  • 📖 If you are adding a user facing feature or make a change of the behavior, please verify that you have documented it
  • 🧪 100% coverage is not a target but most of the time we would rather have a unit test if you make a code change.
  • 🎁 If that's something that is possible to do please ensure to check if we can add a e2e test.
  • 🔎 If there is a flakiness in the CI tests then don't necessary ignore it, better get the flakyness fixed before merging or if that's not possible there is a good reason to bypass it. (token rate limitation may be a good reason to skip).

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Merging #1396 (33b6b70) into main (03bdd33) will decrease coverage by 0.08%.
The diff coverage is 25.00%.

@@            Coverage Diff             @@
##             main    #1396      +/-   ##
==========================================
- Coverage   61.28%   61.20%   -0.08%     
==========================================
  Files         136      136              
  Lines       10026    10045      +19     
==========================================
+ Hits         6144     6148       +4     
- Misses       3389     3399      +10     
- Partials      493      498       +5     
Files Changed Coverage Δ
pkg/provider/github/github.go 74.32% <25.00%> (-2.89%) ⬇️

@chmouel chmouel force-pushed the issue-1395-cannot-resolve-from-branch-with-special-character branch from d70566a to e229601 Compare August 29, 2023 13:04
We need to handle branch name with slash in the name, eg: feature/branch
The user can url encode it with the %2F character, and we are able to parse it
properly.

Fixes openshift-pipelines#1395

Signed-off-by: Chmouel Boudjnah <[email protected]>
@chmouel chmouel force-pushed the issue-1395-cannot-resolve-from-branch-with-special-character branch from e229601 to 33b6b70 Compare August 29, 2023 13:30
@savitaashture
Copy link
Member

/lgtm

},
{
name: "Split URL with encoding emoji in branch",
url: "https://github.com/openshift-pipelines/pipelines-as-code/blob/%F0%9F%99%83/filename.yaml",
Copy link
Member

@savitaashture savitaashture Aug 30, 2023

Choose a reason for hiding this comment

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

Suggested change
url: "https://github.com/openshift-pipelines/pipelines-as-code/blob/%F0%9F%99%83/filename.yaml",
url: "https://github.com/openshift-pipelines/pipelines-as-code/blob/%F0%9F%99%83/filename.yaml",

%F0%9F%99%83

are these standard code for emoji ?

Copy link
Member

Choose a reason for hiding this comment

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

Ah i asked chat gpt 😁

The text "%F0%9F%99%83" is a URL-encoded representation of the emoji

@savitaashture savitaashture merged commit 6a2f9c4 into openshift-pipelines:main Aug 30, 2023
5 checks passed
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.

Cannot resolve from branch with special character
3 participants