This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Handle Enterprise http urls #21
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fe26c35
Add a ToWebUri method to UriString
haacked 675c82c
Add method for appending relative paths to urls
haacked 7cfd1a1
:fire: Remove the ToHttps method
haacked f401897
Preserve HTTP scheme for enterprise repositories
haacked ac526ca
Use UriString and remove duplicate parsing logic
haacked b5249ab
Include AccountCacheItemTests
haacked 4f726d9
Include this in the project too.
haacked f09fb86
ToWebUrl needs to normalize URLs
haacked 5a01995
:art: Rename ToWebUri to ToRepositoryUrl
haacked 56add34
Make sure we don't crash with file remote origin
haacked 2232405
Explicitly call string static methods
haacked 53ba917
This can be made readonly
haacked dc96ded
:art: Sort and remove unused usings
haacked 59bb542
Move exception handling inside the method
haacked File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using System; | ||
using GitHub.Primitives; | ||
|
||
namespace GitHub.Api | ||
{ | ||
public interface ISimpleApiClientFactory | ||
{ | ||
ISimpleApiClient Create(Uri repoUrl); | ||
ISimpleApiClient Create(UriString repositoryUrl); | ||
void ClearFromCache(ISimpleApiClient client); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility; | ||
using GitHub.Models; | ||
using GitHub.Info; | ||
using GitHub.Primitives; | ||
|
||
namespace GitHub.VisualStudio | ||
{ | ||
|
@@ -127,7 +128,7 @@ public static Uri GetRepoUrlFromSolution(IVsSolution solution) | |
return null; | ||
using (var repo = new Repository(repoPath)) | ||
{ | ||
return GetUriFromRepository(repo); | ||
return GetUriFromRepository(repo)?.ToRepositoryUrl(); | ||
} | ||
} | ||
|
||
|
@@ -144,21 +145,13 @@ public static Repository GetRepoFromSolution(this IVsSolution solution) | |
return new Repository(repoPath); | ||
} | ||
|
||
public static Uri GetUriFromRepository(Repository repo) | ||
public static UriString GetUriFromRepository(Repository repo) | ||
{ | ||
if (repo == null) | ||
return null; | ||
var remote = repo.Network.Remotes.FirstOrDefault(x => x.Name.Equals("origin", StringComparison.Ordinal)); | ||
if (remote == null) | ||
return null; | ||
Uri uri; | ||
var url = remote.Url; | ||
// fixup ssh urls | ||
if (url.StartsWith("git@github.com:", StringComparison.Ordinal)) | ||
url = url.Replace("git@github.com:", "https://github.com/"); | ||
if (!Uri.TryCreate(url, UriKind.Absolute, out uri)) | ||
return null; | ||
return uri; | ||
return repo | ||
?.Network | ||
.Remotes | ||
.FirstOrDefault(x => x.Name.Equals("origin", StringComparison.Ordinal)) | ||
?.Url; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotta love them null conditional operators! ❤️ |
||
} | ||
|
||
public static Repository GetRepoFromIGit(this IGitRepositoryInfo repoInfo) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there an advantage to doing this with the value type instead of the class type?
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.
Nope. I think it's my overeager R# that does this. We should pick an approach and stick to it. Do you have a preference?
BTW, this has nothing to do with value type or class type.
string
is just the shorthand forSystem.String
but it's the exact same class. 😄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.
Weeell, I always type String.Something out of habit, so I'm sure the code is way more sprinkled with the uppercase version than the lowercase one (and I doubt I can teach my fingers otherwise...) 😄
Yeah, I keep forgetting we're in .NET land where there are no crazy peeps doing weird stuff with jit and string/String differences...