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
Bug 1924143: Create application edit url based on git provider #8028
Bug 1924143: Create application edit url based on git provider #8028
Conversation
@rottencandy: This pull request references Bugzilla bug 1924143, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @sahil143 @jerolimov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the refactoring and direction but have some small ideas here. Esp. we should support also custom domains when possible.
return { | ||
'app.openshift.io/vcs-uri': gitURL, | ||
'app.openshift.io/vcs-ref': ref, | ||
'app.openshift.io/vcs-ref': gitRef || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not default here to master (or main?) anymore in the annotations? This is not required as part of this change, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates problems for repos where the default branch is not master. For ex: https://github.com/redhat-developer/s2i-dotnetcore-ex or https://github.com/eggheadio/egghead-next
The edit icon then gets this incorrect branch name and adds it to the url, which leads to 404. I think that not having a branch in url is better than assuming an incorrect branch.
But I can undo this if it is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds valid for me. You can keep this.
I thought the gitRef was set in these cases. Can you check where we "lose" the branch info in the add flow for these repos? I really would like to see their branch names here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we do not try to fetch the the default branch if the ref isn't provided, so it never gets set in the first place:
https://github.com/openshift/console/blob/master/frontend/packages/git-service/src/services/github-service.ts#L83
The git APIs do not require branch to be supplied, and will operate on the default branch.
So unless a ref is provided by user, it will not be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParseBitbucketUrl() seems to provide branch as well which is used for default branch if a ref is not provided (
const { name, owner, host, branch } = ParseBitbucketUrl(this.gitsource.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to extract branch name from the URL, and return 'master' if there is no branch.
https://github.com/codefresh-io/parse-bitbucket-url/blob/master/index.js#L189
it('should return full git url for GitHub URI', () => { | ||
const mockGitURI = 'https://github.com/openshift/console'; | ||
const editUrl = getEditURL(mockGitURI, 'branch1'); | ||
expect(editUrl).toBe('https://github.com/openshift/console/tree/branch1'); | ||
}); | ||
|
||
it('should return full git url for GitLab URI', () => { | ||
const mockGitURI = 'https://gitlab.com/example/reponame'; | ||
const editUrl = getEditURL(mockGitURI, 'branch1'); | ||
expect(editUrl).toBe('https://gitlab.com/example/reponame/-/tree/branch1'); | ||
}); | ||
|
||
it('should return full git url for Bitbucket URI', () => { | ||
const mockGitURI = 'https://bitbucket.org/username/examplerepo'; | ||
const editUrl = getEditURL(mockGitURI, 'branch1'); | ||
expect(editUrl).toBe('https://bitbucket.org/username/examplerepo/src/branch1'); | ||
}); | ||
|
||
it('should return only git url for repo from non-supported git provider', () => { | ||
const mockGitURI = 'https://example.com/username/examplerepo'; | ||
const editUrl = getEditURL(mockGitURI, 'branch1'); | ||
expect(editUrl).toBe('https://example.com/username/examplerepo'); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add also cases for custom domains like github.example.com
, gitlab.example.com
and bitbucket.example.com
? In this cases I also expect the full GitHub branch pathname.
I expect we can not determinate git.example.com
, but that's acceptable for me at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
a286cf6
to
a4a4167
Compare
a4a4167
to
a4e42e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it with GitHub and GitLab and works fine for me. Also know that the URL schema is valid for BitBucket. I noticed that it would also be cool at attach the contextDir if used, but this is another issue. ;)
/lgtm
/assign @rohitkrai03 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jerolimov, rohitkrai03, rottencandy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@rottencandy: All pull requests linked via external trackers have merged: Bugzilla bug 1924143 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherrypick release-4.6 |
@rottencandy: #8028 failed to apply on top of branch "release-4.6":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-5459
Analysis / Root cause:
There is no standard way for git providers to display a repository's branch.
Solution Description:
master
in import flow if branch is not provided, as this fails for branches whose default branch is not master.Unit test coverage report:
Added tests.
Browser conformance:
/kind bug