From 59ba922472209b54826738ae7a107c597b668fdf Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 7 Jun 2023 08:16:22 +0800 Subject: [PATCH] add git log context fore relase note command --- src/context/customContext.ts | 5 ++++- src/util/commonUtil.ts | 22 +++++++++++++++++++ .../git_log_for_releasenote/_setting_.json | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 workflows/default/context/git_log_for_releasenote/_setting_.json diff --git a/src/context/customContext.ts b/src/context/customContext.ts index 63d3728..b659b24 100644 --- a/src/context/customContext.ts +++ b/src/context/customContext.ts @@ -2,7 +2,7 @@ import fs from 'fs'; import path from 'path'; import { logger } from '../util/logger'; -import { runCommandStringArrayAndWriteOutput, CommandResult } from '../util/commonUtil'; +import { runCommandStringArrayAndWriteOutput, runCommandStringAndWriteOutputSync, CommandResult } from '../util/commonUtil'; export interface CustomContext { @@ -85,6 +85,9 @@ class CustomContexts { commandArray[index] = arg.replace('${CurDir}', contextDir); }); + if (commandArray.length === 1) { + return runCommandStringAndWriteOutputSync(commandArray[0], outputFile); + } return await runCommandStringArrayAndWriteOutput(commandArray, outputFile); } } diff --git a/src/util/commonUtil.ts b/src/util/commonUtil.ts index 332691e..c655a44 100644 --- a/src/util/commonUtil.ts +++ b/src/util/commonUtil.ts @@ -180,4 +180,26 @@ export async function getLanguageIdByFileName(fileName: string): Promise { + const data = { + "command": command, + "content": stdout, + }; + return JSON.stringify(data); + }; + fs.writeFileSync(outputFile, onOutputFile(command, output)); + return { exitCode: 0, stdout: output, stderr: '' } + } catch (error) { + logger.channel()?.error(`Error occurred: ${error}`); + logger.channel()?.show(); + return { exitCode: 1, stdout: '', stderr: String(error) } + } } \ No newline at end of file diff --git a/workflows/default/context/git_log_for_releasenote/_setting_.json b/workflows/default/context/git_log_for_releasenote/_setting_.json new file mode 100644 index 0000000..30211f0 --- /dev/null +++ b/workflows/default/context/git_log_for_releasenote/_setting_.json @@ -0,0 +1,5 @@ +{ + "name": "git_log_releasenote", + "description": "git log for write release note", + "command": ["git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:\"%h - %B\""] +} \ No newline at end of file