Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion Apps.GitLab/Actions/RepositoryActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ public async Task<GetFileResponse> GetFile(
repository.WebUrl,
branch,
RestClient.BaseUrl);
var fileData = FileHelper.ProcessDownloadedFile(fileToProcess, InvocationContext.Logger, getFileRequest.LanguageCode, getFileRequest.ContentId);
var fileData = FileHelper.ProcessDownloadedFile(
fileToProcess,
InvocationContext.Logger,
getFileRequest.LanguageCode,
getFileRequest.ContentId,
getFileRequest.ContentName);

var fileReference = await fileManagementClient.UploadAsync(fileData.FileStream, fileData.MimeType, fileData.FileName);
return new GetFileResponse
Expand Down
4 changes: 2 additions & 2 deletions Apps.GitLab/Apps.GitLab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<Nullable>enable</Nullable>
<Product>GitLab</Product>
<Description>GitLab is a developer platform that allows developers to create, store, and manage their code. This app focuses on connecting repository events and file actions into the Blackbird ecosystem.</Description>
<Version>1.0.16</Version>
<Version>1.0.17</Version>
<AssemblyName>Apps.GitLab</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blackbird.Applications.SDK.Blueprints" Version="1.0.2" />
<PackageReference Include="Blackbird.Applications.SDK.Extensions.FileManagement" Version="1.1.0" />
<PackageReference Include="Blackbird.Applications.Sdk.Utils" Version="1.0.26" />
<PackageReference Include="Blackbird.Filters" Version="1.2.9" />
<PackageReference Include="Blackbird.Filters" Version="1.2.11" />
<PackageReference Include="GitLabApiClient" Version="1.8.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
Expand Down
3 changes: 3 additions & 0 deletions Apps.GitLab/Models/Respository/Requests/GetFileRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ public class GetFileRequest

[Display("Content ID", Description = "The ID of the content, used by Blacklake when diffing.")]
public string? ContentId { get; set; }

[Display("Content name")]
public string? ContentName { get; set; }
}
11 changes: 8 additions & 3 deletions Apps.GitLab/Utils/File/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ namespace Apps.GitLab.Utils.File;

public static class FileHelper
{
public static ProcessedDownloadedFile ProcessDownloadedFile(DownloadedFile downloadedFile, Logger? logger, string? language, string? contentId)
public static ProcessedDownloadedFile ProcessDownloadedFile(
DownloadedFile downloadedFile,
Logger? logger,
string? language,
string? contentId,
string? contentName)
{
var filename = Path.GetFileName(downloadedFile.Path);
if (!MimeTypes.TryGetMimeType(filename, out var mimeType))
Expand All @@ -32,10 +37,10 @@ public static ProcessedDownloadedFile ProcessDownloadedFile(DownloadedFile downl
fileContent.Language = language;
fileContent.SystemReference.ContentId = contentId;
fileContent.SystemReference.AdminUrl = editUrl;
fileContent.SystemReference.ContentName = filename;
fileContent.SystemReference.ContentName = string.IsNullOrWhiteSpace(contentName) ? filename : contentName;
fileContent.SystemReference.SystemName = "Gitlab";
fileContent.SystemReference.SystemRef = "https://gitlab.com/";

return new(fileContent.ToStream(), mimeType, filename);
}
}
}