-
Notifications
You must be signed in to change notification settings - Fork 349
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: Determine SCM and parse clone url in GitProvenance for more accurate path/origin/organiation/groups #4367
Conversation
Determine the SCM from a list of known urls and any manually registered SCMs. The SCM is then used to determine ScmUrlComponents which in turn give information about a repository.
rewrite-core/src/main/java/org/openrewrite/scm/GroupPathScm.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/scm/ScmUrlComponents.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/scm/AzureDevopsCloneUrl.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/AzureDevOpsScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/GitLabScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…eUrl.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
rewrite-core/src/test/java/org/openrewrite/scm/BitbucketServerScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/GitLabScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/SimpleScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UnknownScmTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/scm/UrlComponentsTest.java
Outdated
Show resolved
Hide resolved
Resolved these issues with a quick recipe run from the IntelliJ IDEA plugin through type: specs.openrewrite.org/v1beta/recipe
name: Scratch rewrite.yml
recipeList:
- org.openrewrite.java.format.EmptyNewlineAtEndOfFile The full list of checks on every pull request is maintained here: rewrite/.github/workflows/receive-pr.yml Lines 21 to 84 in 4568577
I'm considering adding that to a root |
rewrite-core/src/test/java/org/openrewrite/scm/GitLabScmTest.java
Outdated
Show resolved
Hide resolved
Ah that's what it was trying to do. The suggestions were not showing that and not applyable.. Yeah sound like a good plan! |
just talked to Bryce about azuredevops and this came up. We require configuration of baseurl in moderne CLI/agent. curious about this. |
* refactor: Azure DevOps refactoring. * review changes * review changes --------- Co-authored-by: Peter Streef <[email protected]>
rewrite-core/src/main/java/org/openrewrite/scm/AzureDevOpsScm.java
Outdated
Show resolved
Hide resolved
this.autocrlf = autocrlf; | ||
this.eol = eol; | ||
this.committers = committers; | ||
cloneUrl = parseCloneUrl(origin); |
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.
We should probably only calculate this when it is first used, otherwise this slows down deserialization.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
*/ | ||
@Deprecated |
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'm not sure it's necessary to deprecate since it is in widespread use. Fine to have a convenience method for organization on CloneUrl
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.
actually I think we should point back to the "old" method that does not take an argument, and deprecate this one which (again) takes the origin (with scheme).
replaced by #4381 |
What's changed?
Determine the SCM from a list of known urls and any manually registered SCMs. The SCM is then used to parse a typed
CloneUrl
which in turn give information about a repository. Depending on the SCM there are some expectations about the clone url that must be met.What's your motivation?
To determine the repository origin, path, organization, project and group path (for GitLab) is tricky, especially with self-hosted SCMs. Doing this in 1 place makes it more maintainable.
Anything in particular you'd like reviewers to focus on?
Any url patterns that are missed
Anyone you would like to review specifically?
@bryceatmoderne
Have you considered any alternatives or workarounds?
Implementing this in higher level code/places.
Any additional context
This is going to be used directly by Moderne CLI, but should be useful for other projects as well.
Checklist