From 4393b13ec6ea485371a4f551d5f11fe954b74953 Mon Sep 17 00:00:00 2001 From: surfaceyu Date: Fri, 12 Jul 2024 16:52:00 +0800 Subject: [PATCH 1/2] 1.add copy msg more cmd template like this `\nRevision: %s\nAuthor: %s\nDate: %s\nMessage:\n%s\n%s` --- package.json | 26 ++++++++++++++++++++++++++ src/historyView/common.ts | 11 +++++++++++ src/historyView/itemLogProvider.ts | 4 ++++ src/historyView/repoLogProvider.ts | 4 ++++ 4 files changed, 45 insertions(+) diff --git a/package.json b/package.json index b4998738..b1a065db 100644 --- a/package.json +++ b/package.json @@ -202,6 +202,11 @@ "category": "SVN", "title": "Copy message" }, + { + "command": "svn.itemlog.copymsgmore", + "category": "SVN", + "title": "Copy message more" + }, { "command": "svn.itemlog.copyrevision", "category": "SVN", @@ -331,6 +336,11 @@ "category": "SVN", "title": "Copy message" }, + { + "command": "svn.repolog.copymsgmore", + "category": "SVN", + "title": "Copy message more" + }, { "command": "svn.repolog.copyrevision", "category": "SVN", @@ -485,6 +495,10 @@ "command": "svn.itemlog.copymsg", "when": "false" }, + { + "command": "svn.itemlog.copymsgmore", + "when": "false" + }, { "command": "svn.itemlog.copyrevision", "when": "false" @@ -577,6 +591,10 @@ "command": "svn.repolog.copymsg", "when": "false" }, + { + "command": "svn.repolog.copymsgmore", + "when": "false" + }, { "command": "svn.repolog.copyrevision", "when": "false" @@ -716,6 +734,10 @@ "command": "svn.itemlog.copymsg", "when": "view == itemlog && viewItem == diffable" }, + { + "command": "svn.itemlog.copymsgmore", + "when": "view == itemlog && viewItem == diffable" + }, { "command": "svn.itemlog.copyrevision", "when": "view == itemlog && viewItem == diffable" @@ -740,6 +762,10 @@ "command": "svn.repolog.copymsg", "when": "view == repolog && viewItem == commit" }, + { + "command": "svn.repolog.copymsgmore", + "when": "view == repolog && viewItem == commit" + }, { "command": "svn.repolog.copyrevision", "when": "view == repolog && viewItem == commit" diff --git a/src/historyView/common.ts b/src/historyView/common.ts index c529352e..c6759252 100644 --- a/src/historyView/common.ts +++ b/src/historyView/common.ts @@ -17,6 +17,7 @@ import { configuration } from "../helpers/configuration"; import { IRemoteRepository } from "../remoteRepository"; import { SvnRI } from "../svnRI"; import { tempSvnFs } from "../temp_svn_fs"; +import { format } from "util"; dayjs.extend(relativeTime); @@ -91,6 +92,16 @@ export async function copyCommitToClipboard(what: string, item: ILogTreeItem) { case "msg": case "revision": await clipboard.writeText(commit[what]); + break; + case "msg_more": + let msg_template = `\nRevision: %s\nAuthor: %s\nDate: %s\nMessage:\n%s\n%s` + let paths = "" + commit.paths.forEach(element => { + paths = paths + format("%s: %s\n", element.action, element._) + }); + // 输出 format + let s = format(msg_template, commit.revision, commit.author, dayjs(commit.date).format("YYYY年MM月DD日 HH:mm:ss"), commit.msg, paths) + await clipboard.writeText(s); } } } diff --git a/src/historyView/itemLogProvider.ts b/src/historyView/itemLogProvider.ts index 6dea04cd..15a378fc 100644 --- a/src/historyView/itemLogProvider.ts +++ b/src/historyView/itemLogProvider.ts @@ -51,6 +51,10 @@ export class ItemLogProvider "svn.itemlog.copymsg", async (item: ILogTreeItem) => copyCommitToClipboard("msg", item) ), + commands.registerCommand( + "svn.itemlog.copymsgmore", + async (item: ILogTreeItem) => copyCommitToClipboard("msg_more", item) + ), commands.registerCommand( "svn.itemlog.copyrevision", async (item: ILogTreeItem) => copyCommitToClipboard("revision", item) diff --git a/src/historyView/repoLogProvider.ts b/src/historyView/repoLogProvider.ts index 79200aaf..5c21b993 100644 --- a/src/historyView/repoLogProvider.ts +++ b/src/historyView/repoLogProvider.ts @@ -91,6 +91,10 @@ export class RepoLogProvider "svn.repolog.copymsg", async (item: ILogTreeItem) => copyCommitToClipboard("msg", item) ), + commands.registerCommand( + "svn.repolog.copymsgmore", + async (item: ILogTreeItem) => copyCommitToClipboard("msg_more", item) + ), commands.registerCommand( "svn.repolog.copyrevision", async (item: ILogTreeItem) => copyCommitToClipboard("revision", item) From e5772de72c32c7b2fd2e6519d9863762a020c404 Mon Sep 17 00:00:00 2001 From: surfaceyu Date: Fri, 12 Jul 2024 17:04:11 +0800 Subject: [PATCH 2/2] 1.fix format --- src/historyView/common.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/historyView/common.ts b/src/historyView/common.ts index c6759252..715abf08 100644 --- a/src/historyView/common.ts +++ b/src/historyView/common.ts @@ -94,13 +94,20 @@ export async function copyCommitToClipboard(what: string, item: ILogTreeItem) { await clipboard.writeText(commit[what]); break; case "msg_more": - let msg_template = `\nRevision: %s\nAuthor: %s\nDate: %s\nMessage:\n%s\n%s` - let paths = "" + let msg_template = `\nRevision: %s\nAuthor: %s\nDate: %s\nMessage:\n%s\n%s`; + let paths = ""; commit.paths.forEach(element => { - paths = paths + format("%s: %s\n", element.action, element._) + paths = paths + format("%s: %s\n", element.action, element._); }); // 输出 format - let s = format(msg_template, commit.revision, commit.author, dayjs(commit.date).format("YYYY年MM月DD日 HH:mm:ss"), commit.msg, paths) + let s = format( + msg_template, + commit.revision, + commit.author, + dayjs(commit.date).format("YYYY年MM月DD日 HH:mm:ss"), + commit.msg, + paths + ); await clipboard.writeText(s); } }