Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

We only need one url for a repo #637

Merged
merged 5 commits into from
Jan 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
This works if the github urls are always in the same form
i.e. without the ".git" suffix
  • Loading branch information
Anthony Steele committed Jan 19, 2019
commit 9f5aaa3787c34698226cd600ac839a5297524ed1
19 changes: 17 additions & 2 deletions NuKeeper.GitHub/GitHubRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@

namespace NuKeeper.GitHub
{
public class GitHubRepository : Abstractions.CollaborationModels.Repository
public class GitHubRepository : Repository
{
public GitHubRepository(Octokit.Repository repository)
: base(
repository.Name,
repository.Archived,
repository.Permissions != null ?
new UserPermissions(repository.Permissions.Admin, repository.Permissions.Push, repository.Permissions.Pull) : null,
new Uri(repository.CloneUrl),
GithubUri(repository.CloneUrl),
new User(repository.Owner.Login, repository.Owner.Name, repository.Owner.Email),
repository.Fork,
repository.Parent != null ?
new GitHubRepository(repository.Parent) : null
)
{
}

private static Uri GithubUri(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return null;
}

if (value.EndsWith(".git", StringComparison.OrdinalIgnoreCase))
{
value = value.Substring(0, value.Length - 4);
}

return new Uri(value, UriKind.Absolute);
}
}
}