Fix gitlab scaffoler publisher

This commit is contained in:
Thibault Cohen
2021-01-08 10:27:40 -05:00
parent 730a54c3a9
commit 5eb8c9b9ef
3 changed files with 14 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend': minor
---
Fix gitlab scaffoler publisher
@@ -20,6 +20,7 @@ import { JsonValue } from '@backstage/config';
import { initRepoAndPush } from './helpers';
import { RequiredTemplateValues } from '../templater';
export class GitlabPublisher implements PublisherBase {
private readonly client: Gitlab;
private readonly token: string;
@@ -52,7 +53,10 @@ export class GitlabPublisher implements PublisherBase {
private async createRemote(
values: RequiredTemplateValues & Record<string, JsonValue>,
) {
const [owner, name] = values.storePath.split('/');
const pathElements = values.storePath.split('/');
const name = pathElements[pathElements.length - 1];
pathElements.pop();
const owner = pathElements.join('/');
let targetNamespace = ((await this.client.Namespaces.show(owner)) as {
id: number;
@@ -45,6 +45,10 @@ export async function initRepoAndPush({
dot: true,
});
await git.init({
dir,
});
for (const filepath of paths) {
await git.add({ dir, filepath });
}