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

[#1572] Accept different types of URLs besides https github #1644

Merged
merged 133 commits into from
Mar 28, 2022

Conversation

chan-j-d
Copy link
Contributor

@chan-j-d chan-j-d commented Feb 2, 2022

Resolves #1572

Commit message:

The repo location verification performed in RepoLocation is too 
restrictive and rejects many otherwise valid git clone targets. 
External links in the generated webpage also hardcode parts of the
link to be GitHub specific.

This change would allow RepoSense to work with a greater variety of 
locations both remote and local while still providing an appropriate
guess for the organization and repo-name. 

The way external links are generated in the frontend has also been 
changed to support GitHub, GitLab and BitBucket. Support has also 
been implemented to easily include other domain names if needed.

Unsupported repository links (local or unsupported remote) will no
longer open an external webpage when clicked.

Let's allow RepoSense to work with a greater variety of locations.

Backend Changes

This change removes direct validation of location based on the URL provided as was done in the previous implementation. This might indirectly fix the issue #1641. This implementation now provides a best guess of the repo name and 'organization' via regex match based on https://git-scm.com/docs/git-clone#_git_urls.

The method of guessing for remote repos is such: Given a URL https://host.xz[:port]/path/to/repo.git/, it drops the domain and keeps the path/to/repo.git. The last directory becomes the repo-name and the path/to has the / changed to a - and becomes the organization.

Local repositories are sorted similarly. This allows differentiation between two local directories with the same final directory although this can result in some awkward organization names. E.g. the path ../reposense/RepoSense will have organization ..-reposense. The benefit is that two different paths provided will always provide two unique output directories. This should also fix the issue #1637 but I will investigate it separately.

The class SupportedDomainUrlMap has also been added to be the 'single source of truth' for which types of remote repository domains we would like to support. Adding a new domain can be easily done by adding a new entry to the map. The map provides template mappings for how things like the file blame URL and file history URL would look like. The information is uploaded via summary.json.

Related PRs (that are possibly under review but already merged to this PR):

Frontend Changes
The template links are uploaded via summary.json and stored in window.DOMAIN_URL_MAP.

The way the various types of links are generated (file history, author profile, repo url) have been aggregated in api.js. All other files that generated their own links have been edited to use one of the methods from api.js.

Currently, the buttons that leads to once-invalid links will not open anything. This is an improvement over the master branch behaviour of opening an invalid link. A follow-up change (not included in this PR) would be to add a message notification if trying to open an unsupported link.

Reviewing this PR
The backend changes relating to the organization and repo-name guessing in RepoLocation (up to commit 60f57e3) have mostly been approved.

I would like reviews regarding the changes after which are dealing with supporting the frontend link generations.
In particular, I would like the frontend code reviewed as I'm not too familiar with the layers of abstraction and design in the frontend code.

How to test
I used the two repositories below for testing.
GitLab repository: https://gitlab.com/tortoisegit/tortoisegit.git
BitBucket repository: https://bitbucket.org/atlassian/atlassian-scheduler.git
Pull the branch https://github.com/chan-j-d/RepoSense/tree/1572-experimental-implementation, build and run something like
gradlew run -Dargs="--repos https://gitlab.com/tortoisegit/tortoisegit.git https://bitbucket.org/atlassian/atlassian-scheduler.git https://github.com/reposense/RepoSense -i --view -s 10/02/2022"

@chan-j-d chan-j-d marked this pull request as draft February 2, 2022 07:40
@chan-j-d chan-j-d marked this pull request as ready for review February 2, 2022 08:00
@chan-j-d
Copy link
Contributor Author

@dcshzj Requesting follow-up review. Thanks!

Copy link
Member

@dcshzj dcshzj left a comment

Choose a reason for hiding this comment

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

Replied to some of the comments, mainly now is about the icon used for the repository.

Copy link
Member

@dcshzj dcshzj left a comment

Choose a reason for hiding this comment

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

LGTM!

@chan-j-d
Copy link
Contributor Author

Follow-up actions are being tracked in this issue #1726

@dcshzj dcshzj changed the title [#1572] Allow RepoSense to accept different types of URLs besides https github [#1572] Accept different types of URLs besides https github (#1644) Mar 28, 2022
@dcshzj dcshzj changed the title [#1572] Accept different types of URLs besides https github (#1644) [#1572] Accept different types of URLs besides https github Mar 28, 2022
@dcshzj dcshzj merged commit 28ab050 into reposense:master Mar 28, 2022
@github-actions
Copy link
Contributor

The following links are for previewing this pull request:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote repos: allow different types of URLs besides the https github type
7 participants