tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
RepositoryIdentifier.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics.CodeAnalysis;
3
6
8{
12 public sealed class RepositoryIdentifier
13 {
17 [MemberNotNullWhen(false, nameof(RepositoryId))]
18 [MemberNotNullWhen(true, nameof(Owner))]
19 [MemberNotNullWhen(true, nameof(Name))]
20 public bool IsSlug => !RepositoryId.HasValue;
21
25 public long? RepositoryId { get; }
26
30 public string? Owner { get; }
31
35 public string? Name { get; }
36
41 public RepositoryIdentifier(long repositoryId)
42 {
43 RepositoryId = repositoryId;
44 }
45
51 public RepositoryIdentifier(string owner, string name)
52 {
53 Owner = owner ?? throw new ArgumentNullException(nameof(owner));
54 Name = name ?? throw new ArgumentNullException(nameof(name));
55 }
56
61 public RepositoryIdentifier(IGitRemoteInformation gitRemoteInformation)
62 {
63 ArgumentNullException.ThrowIfNull(gitRemoteInformation);
64 if (gitRemoteInformation.RemoteGitProvider == RemoteGitProvider.Unknown)
65 throw new ArgumentException("Cannot cast IGitRemoteInformation of Unknown provider to RepositoryIdentifier!", nameof(gitRemoteInformation));
66
67 Owner = gitRemoteInformation.RemoteRepositoryOwner;
68 Name = gitRemoteInformation.RemoteRepositoryName;
69 }
70
72 public override string ToString()
73 => IsSlug
74 ? $"{Owner}/{Name}"
75 : $"ID {RepositoryId.Value}";
76 }
77}
Identifies a repository either by its RepositoryId or Owner and Name.
RepositoryIdentifier(string owner, string name)
Initializes a new instance of the RepositoryIdentifier class.
RepositoryIdentifier(IGitRemoteInformation gitRemoteInformation)
Initializes a new instance of the RepositoryIdentifier class.
bool IsSlug
If the RepositoryIdentifier is using Owner and Name.
RepositoryIdentifier(long repositoryId)
Initializes a new instance of the RepositoryIdentifier class.
string? RemoteRepositoryName
If RemoteGitProvider is not RemoteGitProvider.Unknown this will be set with the name of the repositor...
RemoteGitProvider? RemoteGitProvider
The Models.RemoteGitProvider in use by the repository.
string? RemoteRepositoryOwner
If RemoteGitProvider is not RemoteGitProvider.Unknown this will be set with the owner of the reposito...
RemoteGitProvider
Indicates the remote git host.