Skip to content

Commit 2974ae6

Browse files
committed
(#146) Prevent usage of unsupported functionality
There are some pieces of functionality that currently either don't make sense to support in GitLab. For example, the label command. This command was originally created to plug a hole in missing functionality on GitHub, however the label management in GitLab is far better, and the crude creation of labels from GRM doesn't make sense. Therefore, any attempt to use this command for GitLab returns an error code. Similarly, the addassets command is not supported. This is mainly due to the fact that assets work very differently in GitLab and we need to figure out how to do what is required via the NGitLab library, as I don't think the support currently exists in there. Finally, the updating of comments when closing a milestone also isn't supported, since this also doesn't seem to be supported in NGitLab, but I will be following up with the team over there to make sure.
1 parent b2b62d9 commit 2974ae6

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public AddAssetsCommand(IVcsService vcsService, ILogger logger)
1717

1818
public async Task<int> ExecuteAsync(AddAssetSubOptions options)
1919
{
20+
var vcsOptions = options as BaseVcsOptions;
21+
22+
if (vcsOptions?.Provider == Model.VcsProvider.GitLab)
23+
{
24+
_logger.Error("The addasset command is currently not supported when targetting GitLab.");
25+
return 1;
26+
}
27+
2028
_logger.Information("Uploading assets");
2129
await _vcsService.AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).ConfigureAwait(false);
2230

src/GitReleaseManager.Core/Commands/LabelCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public LabelCommand(IVcsService vcsService, ILogger logger)
1717

1818
public async Task<int> ExecuteAsync(LabelSubOptions options)
1919
{
20+
var vcsOptions = options as BaseVcsOptions;
21+
22+
if (vcsOptions?.Provider == Model.VcsProvider.GitLab)
23+
{
24+
_logger.Error("The label command is currently not supported when targetting GitLab.");
25+
return 1;
26+
}
27+
2028
_logger.Information("Creating standard labels");
2129
await _vcsService.CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName).ConfigureAwait(false);
2230

src/GitReleaseManager.Core/VcsService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ private async Task AddAssetsAsync(string owner, string repository, string tagNam
151151
if (existingAsset != null)
152152
{
153153
_logger.Warning("Requested asset to be uploaded already exists on draft release, replacing with new file: {AssetPath}", asset);
154-
await _vcsProvider.DeleteAssetAsync(owner, repository, existingAsset.Id).ConfigureAwait(false);
154+
155+
if (_vcsProvider is GitLabProvider)
156+
{
157+
_logger.Error("Deleting of assets is not currently supported when targetting GitLab.");
158+
}
159+
else
160+
{
161+
await _vcsProvider.DeleteAssetAsync(owner, repository, existingAsset).ConfigureAwait(false);
162+
}
155163
}
156164

157165
var upload = new ReleaseAssetUpload

0 commit comments

Comments
 (0)