Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @typedef {import('./parse-data')} ParseData
*/

const sprintf = require('sprintf-js').sprintf;

class Generator {
constructor() {
/**
Expand Down Expand Up @@ -93,7 +95,7 @@ class Generator {
*/
_getBranch(name) {
if (this._branches.has(name) === false) {
throw new Error('Branch not created: ' + name);
throw new Error(sprintf('A branch named \'%s\' not created.', name));
}

return this._branches.get(name);
Expand Down
5 changes: 3 additions & 2 deletions src/grammar-support/branch-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const sprintf = require('sprintf-js').sprintf;
const Branch = require('./branch');

/**
Expand All @@ -18,7 +19,7 @@ class BranchList {
*/
add(branch) {
if (this._branches.has(branch)) {
throw new Error('Branch already exists: ' + branch);
throw new Error(sprintf('A branch named \'%s\' already exists.', branch));
}

this._branches.set(branch, new Branch(branch));
Expand All @@ -31,7 +32,7 @@ class BranchList {
*/
get(branch) {
if (!this._branches.has(branch)) {
throw new Error('Branch not created: ' + branch);
throw new Error(sprintf('A branch named \'%s\' not created.', branch));
}

return this._branches.get(branch);
Expand Down
4 changes: 3 additions & 1 deletion src/grammar-support/tag-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const sprintf = require('sprintf-js').sprintf;

class TagList {
constructor() {
/**
Expand All @@ -13,7 +15,7 @@ class TagList {
*/
add(tag) {
if (this._tags.has(tag)) {
throw new Error('Tag already exists: ' + tag);
throw new Error(sprintf('Tag \'%s\' already exists.', tag));
}

this._tags.add(tag);
Expand Down
32 changes: 16 additions & 16 deletions test/input_error_semantics.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = [
git branch foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 02',
Expand All @@ -85,7 +85,7 @@ module.exports = [
git checkout -b foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 03',
Expand All @@ -97,7 +97,7 @@ module.exports = [
git switch -c foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 04',
Expand All @@ -109,7 +109,7 @@ module.exports = [
git branch foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 05',
Expand All @@ -121,7 +121,7 @@ module.exports = [
git checkout -b foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 06',
Expand All @@ -133,7 +133,7 @@ module.exports = [
git switch -c foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 07',
Expand All @@ -145,7 +145,7 @@ module.exports = [
git branch foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 08',
Expand All @@ -157,7 +157,7 @@ module.exports = [
git checkout -b foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 09',
Expand All @@ -169,7 +169,7 @@ module.exports = [
git switch -c foo
`,
line: 6,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 10',
Expand All @@ -180,7 +180,7 @@ module.exports = [
git branch foo
`,
line: 5,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 11',
Expand All @@ -191,7 +191,7 @@ module.exports = [
git checkout -b foo
`,
line: 5,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},
{
case: 'create branch - already created - 12',
Expand All @@ -202,7 +202,7 @@ module.exports = [
git switch -c foo
`,
line: 5,
message: 'Branch already exists: foo',
message: "A branch named 'foo' already exists.",
},

// merge - branch not created
Expand All @@ -213,7 +213,7 @@ module.exports = [
git merge foo
`,
line: 3,
message: 'Branch not created: foo',
message: "A branch named 'foo' not created.",
},
{
case: 'merge - branch not created - 02',
Expand All @@ -223,7 +223,7 @@ module.exports = [
git merge foo
`,
line: 4,
message: 'Branch not created: foo',
message: "A branch named 'foo' not created.",
},

// merge - no commits on branch
Expand Down Expand Up @@ -287,7 +287,7 @@ module.exports = [
git tag v1
`,
line: 5,
message: 'Tag already exists: v1',
message: "Tag 'v1' already exists.",
},
{
case: 'tag - already exists - 02',
Expand All @@ -299,7 +299,7 @@ module.exports = [
git tag v1
`,
line: 6,
message: 'Tag already exists: v1',
message: "Tag 'v1' already exists.",
},

// tag - no commits on branch
Expand Down