From 98d7a441eb407b1d86bd9e5f2bfe200065bef7de Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Mon, 17 Sep 2018 15:06:42 -0300 Subject: [PATCH] feat: Should be able set the commit message for creating branch (Close #338) --- src/commands.ts | 12 +++++++++++- src/repository.ts | 7 +++++-- src/svnRepository.ts | 7 +++++-- src/test/commands.test.ts | 1 + src/test/repository.test.ts | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 9e84a4b8..2423b8da 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -707,7 +707,17 @@ export class SvnCommands implements IDisposable { try { if (branch.isNew) { - await repository.branch(branch.path); + const commitMessage = await window.showInputBox({ + value: `Created new branch ${branch.name}`, + prompt: `Commit message for create branch ${branch.name}` + }); + + // If press ESC on commit message + if (commitMessage === undefined) { + return; + } + + await repository.newBranch(branch.path, commitMessage); } else { await repository.switchBranch(branch.path); } diff --git a/src/repository.ts b/src/repository.ts index 685c466d..791f904c 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -629,9 +629,12 @@ export class Repository { }); } - public async branch(name: string) { + public async newBranch( + name: string, + commitMessage: string = "Created new branch" + ) { return this.run(Operation.NewBranch, async () => { - await this.repository.branch(name); + await this.repository.newBranch(name, commitMessage); this.updateRemoteChangedFiles(); }); } diff --git a/src/svnRepository.ts b/src/svnRepository.ts index 011515dc..00139789 100644 --- a/src/svnRepository.ts +++ b/src/svnRepository.ts @@ -336,7 +336,10 @@ export class Repository { return branches; } - public async branch(name: string) { + public async newBranch( + name: string, + commitMessage: string = "Created new branch" + ) { const repoUrl = await this.getRepoUrl(); const newBranch = repoUrl + "/" + name; const info = await this.getInfo(); @@ -346,7 +349,7 @@ export class Repository { currentBranch, newBranch, "-m", - `Created new branch ${name}` + commitMessage ]); await this.switchBranch(name); diff --git a/src/test/commands.test.ts b/src/test/commands.test.ts index e526f215..7d07f87a 100644 --- a/src/test/commands.test.ts +++ b/src/test/commands.test.ts @@ -171,6 +171,7 @@ suite("Commands Tests", () => { testUtil.overrideNextShowQuickPick(0); testUtil.overrideNextShowQuickPick(1); testUtil.overrideNextShowInputBox("test"); + testUtil.overrideNextShowInputBox("Created new branch test"); await commands.executeCommand("svn.switchBranch"); const repository = model.getRepository(checkoutDir) as Repository; diff --git a/src/test/repository.test.ts b/src/test/repository.test.ts index 7fa50f0b..41972a82 100644 --- a/src/test/repository.test.ts +++ b/src/test/repository.test.ts @@ -133,7 +133,7 @@ suite("Repository Tests", () => { } assert.ok(newRepository); - await newRepository.branch("branches/test"); + await newRepository.newBranch("branches/test"); const currentBranch = await newRepository.getCurrentBranch(); assert.equal(currentBranch, "branches/test");