From 780a869c8f748f14819858d4120cc442aa234804 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Fri, 22 Sep 2023 00:26:33 +0300 Subject: [PATCH] test: debug --- src/main/ts/git.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/ts/git.ts b/src/main/ts/git.ts index 725ded3..a5949f4 100644 --- a/src/main/ts/git.ts +++ b/src/main/ts/git.ts @@ -2,6 +2,7 @@ import child_process from 'node:child_process' import path from 'node:path' import os from 'node:os' import fs from 'node:fs/promises' +import process from 'node:process' import {TAnnotatedTag, TTowerOpts} from './interface' @@ -31,6 +32,15 @@ export const exec = (cmd: string, args?: string[], opts?: any): Promise<{stdout: stderr, duration: Date.now() - now }) + + console.log({ + cmd, + args, + code, + stdout, + stderr, + duration: Date.now() - now + }) }) }) @@ -67,8 +77,11 @@ export const clone = async (url: string, branch = 'tagtower', _cwd?: string) => if (remote.code === 128) { await exec('git', ['init'], opts) await exec('git', ['remote', 'add', 'origin', url], opts) - await exec('git', ['commit', '--allow-empty', '-m', 'init tagtower'], opts) + await setUserConfig(cwd) + await exec('git', ['commit', '--allow-empty', '-m', `init ${branch}`], opts) await exec('git', ['push', 'origin', `HEAD:${branch}`], opts) + } else { + await setUserConfig(cwd) } } @@ -124,3 +137,8 @@ export const deleteTag = async (opts: TTowerOpts & {tag: string}) => { exec('git', ['tag', '--delete', opts.tag], {cwd}) ]) } + +const setUserConfig = async (cwd: string) => { + await exec('git', ['git', 'config', 'user.name', process.env.GIT_COMMITTER_NAME || 'Semrel Extra Bot'], {cwd}) + await exec('git', ['git', 'config', 'user.email', process.env.GIT_COMMITTER_EMAIL || 'semrel-extra-bot@hotmail.com'], {cwd}) +}