Skip to content

Added git url validation for Azure DevOps repositories#134

Open
RobGibbens wants to merge 5 commits into
Dutchskull:developfrom
RobGibbens:develop
Open

Added git url validation for Azure DevOps repositories#134
RobGibbens wants to merge 5 commits into
Dutchskull:developfrom
RobGibbens:develop

Conversation

@RobGibbens

Copy link
Copy Markdown

Azure DevOps repositories have a different format compared to GitHub urls. This update adds RegEx support for Azure DevOps repos, including support for spaces in project names.

Azure DevOps repositories have a different format compared to GitHub urls. This update adds RegEx support for Azure DevOps repos.
Copilot AI review requested due to automatic review settings April 16, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Azure DevOps repository URL support to the existing Git URL validation utility so PolyRepo can accept additional clone URL formats (including percent-encoded spaces in project/repo names).

Changes:

  • Expanded GitUrlUtilities URL validation regex to accept Azure DevOps HTTPS and SSH clone URL formats.
  • Added unit tests covering Azure DevOps URL examples.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Dutchskull.Aspire.PolyRepo/GitUrlUtilities.cs Extends the Git URL validation regex to include Azure DevOps URL patterns.
src/Dutchskull.Aspire.PolyRepo.Tests.Unit/GitUrlUtilitiesTests.cs Adds unit test inputs for Azure DevOps URLs (HTTPS + SSH).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

!string.IsNullOrEmpty(url) && GitUrlRegex().IsMatch(url);

[GeneratedRegex(@"^(?:git|https?|git@[\w\.]+):\/\/[\w\.@\:\/\-~]+\.git(?:\/)?$")]
[GeneratedRegex(@"^(?:(?:git|https?):\/\/[^\s]+\.git(?:\/)?|https:\/\/(?:[\w.-]+@)?dev\.azure\.com\/[^\/\s]+\/[^\/\s]+\/_git\/[^\/\s]+(?:\/)?|git@ssh\.dev\.azure\.com:v3\/[^\/\s]+\/[^\/\s]+\/[^\/\s]+(?:\/)?)$")]

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

The new Azure DevOps patterns allow percent-encoded names (e.g., %20), but GetProjectNameFromGitUrl later derives the local folder name by taking the last / segment verbatim. With Azure DevOps URLs this will produce a repository path containing %20 sequences instead of spaces (and other escaped characters), which is likely not the intended behavior given the goal of supporting spaces in project names. Consider URL-decoding the extracted segment(s) before using them as a directory name (and ensure decoding is safe for filesystem paths).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment thread src/Dutchskull.Aspire.PolyRepo.Tests.Unit/GitUrlUtilitiesTests.cs

@WhiteOlivierus WhiteOlivierus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the intrest and the pr. Love to see test because it makes my life easier. I have one ask. But the feature would be welcome.

{
internal static string GetProjectNameFromGitUrl(string gitUrl) =>
gitUrl.RemovePostfix(".git").Split('/')[^1];
internal static string GetProjectNameFromGitUrl(string gitUrl)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it maybe an idea to create a Uri object and get the segment you want by index? The reason I did some string math before is because it was a simple Uri. Now that it is more complex, a more simple solution that would scale would be nice.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Are you looking for "simpler", or more performant? I just pushed some changes with some optimizations for parsing and validation the URI.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would like it simpler. Because I can image gitea and gitlab also having different Uri's and then it is interesting to just have a index to change of which segment of the uri you want to have.

I am moving, so it could be that I will react after Monday.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants