2using System.Globalization;
4using System.Threading.Tasks;
6using Microsoft.Extensions.Logging;
24 public const string GitLabUrl =
"https://gitlab.com";
41 : base(logger, remoteUrl)
49 CancellationToken cancellationToken)
54 var operationResult = await client.GraphQL.GetMergeRequest.ExecuteAsync(
55 $
"{RemoteRepositoryOwner}/{RemoteRepositoryName}",
56 parameters.
Number.ToString(CultureInfo.InvariantCulture),
59 operationResult.EnsureNoErrors();
60 var mr = operationResult.Data?.Project?.MergeRequest ??
throw new InvalidOperationException(
"GitLab MergeRequest check returned null!");
64 Author = mr.
Author?.Username,
65 BodyAtMerge = mr.Description,
66 TitleAtMerge = mr.Title,
68 Number = parameters.
Number,
69 TargetCommitSha = mr.DiffHeadSha,
75 Logger.LogWarning(ex,
"Error retrieving merge request metadata!");
80 BodyAtMerge = ex.Message,
81 TitleAtMerge = ex.Message,
83 Number = parameters.
Number,
85 Url = $
"https://gitlab.com/{RemoteRepositoryOwner}/{RemoteRepositoryName}/-/merge_requests/{parameters.Number}",
string? Author
The author of the test merge source.
Represents configurable settings for a git repository.
string? AccessToken
The token/password to access the git repository with. Can also be a TGS encoded app private key....
Parameters for creating a TestMerge.
virtual ? string TargetCommitSha
The sha of the test merge revision to merge. If not specified, the latest commit from the source will...
string? Comment
Optional comment about the test.
int Number
The number of the test merge source.
GitLab IGitRemoteFeatures.
override async ValueTask< Models.TestMerge > GetTestMergeImpl(TestMergeParameters parameters, RepositorySettings repositorySettings, CancellationToken cancellationToken)
override string TestMergeLocalBranchNameFormatter
Get.
const string GitLabUrl
Url for main GitLab site.
GitLabRemoteFeatures(ILogger< GitLabRemoteFeatures > logger, Uri remoteUrl)
Initializes a new instance of the GitLabRemoteFeatures class.
override string TestMergeRefSpecFormatter
Gets a formatter string which creates the remote refspec for fetching the HEAD of passed in test merg...
Base class for implementing IGitRemoteFeatures.
ILogger< GitRemoteFeaturesBase > Logger
The ILogger for the GitRemoteFeaturesBase.
Factory for creating IGraphQLGitLabClients.
static async ValueTask< IGraphQLGitLabClient > CreateClient(string? bearerToken=null)
Sets up a IGraphQLGitLabClient.
RemoteGitProvider
Indicates the remote git host.