Skip to content

Commit

Permalink
(#146) Prevent usage of unsupported functionality
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gep13 committed Oct 4, 2023
1 parent 1199e2d commit 2828133
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public AddAssetsCommand(IVcsService vcsService, ILogger logger)

public async Task<int> ExecuteAsync(AddAssetSubOptions options)
{
var vcsOptions = options as BaseVcsOptions;

if (vcsOptions?.Provider == Model.VcsProvider.GitLab)
{
_logger.Error("The addasset command is currently not supported when targetting GitLab.");
return 1;
}

_logger.Information("Uploading assets");
await _vcsService.AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).ConfigureAwait(false);

Expand Down
8 changes: 8 additions & 0 deletions src/GitReleaseManager.Core/Commands/LabelCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public LabelCommand(IVcsService vcsService, ILogger logger)

public async Task<int> ExecuteAsync(LabelSubOptions options)
{
var vcsOptions = options as BaseVcsOptions;

if (vcsOptions?.Provider == Model.VcsProvider.GitLab)
{
_logger.Error("The label command is currently not supported when targetting GitLab.");
return 1;
}

_logger.Information("Creating standard labels");
await _vcsService.CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName).ConfigureAwait(false);

Expand Down
10 changes: 9 additions & 1 deletion src/GitReleaseManager.Core/VcsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ private async Task AddAssetsAsync(string owner, string repository, string tagNam
if (existingAsset != null)
{
_logger.Warning("Requested asset to be uploaded already exists on draft release, replacing with new file: {AssetPath}", asset);
await _vcsProvider.DeleteAssetAsync(owner, repository, existingAsset.Id).ConfigureAwait(false);

if (_vcsProvider is GitLabProvider)
{
_logger.Error("Deleting of assets is not currently supported when targetting GitLab.");
}
else
{
await _vcsProvider.DeleteAssetAsync(owner, repository, existingAsset).ConfigureAwait(false);
}
}

var upload = new ReleaseAssetUpload
Expand Down

0 comments on commit 2828133

Please sign in to comment.