From d97be6025a8b6730c5181c052b3cbf919d5f90d4 Mon Sep 17 00:00:00 2001 From: Charlike Mike Reagent Date: Tue, 6 Nov 2018 22:55:59 +0200 Subject: [PATCH] major(release): optimize, add tests, local gitconfig in CI Signed-off-by: Charlike Mike Reagent --- test/index.js | 3 +++ test/snapshots/index.snapshot.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index d9366f4..798e726 100644 --- a/test/index.js +++ b/test/index.js @@ -28,6 +28,9 @@ test('basic test', async (t) => { filemode = true bare = false logallrefupdates = true + [user] + name = Foo Bar Baz + email = foobar@example.com [commit] gpgsign = false`; diff --git a/test/snapshots/index.snapshot.json b/test/snapshots/index.snapshot.json index 54903b2..d5b1381 100644 --- a/test/snapshots/index.snapshot.json +++ b/test/snapshots/index.snapshot.json @@ -1 +1 @@ -{"basic test":{"skip":false,"todo":false,"run":false,"isPending":false,"isRejected":false,"isFulfilled":true,"id":1,"str":"async (t) => {\n const fakeCwd = path.join(__dirname, 'fixtures', 'qq5');\n await fs.remove(fakeCwd);\n await charlike({\n project: { name: 'qq5' },\n locals: { version: '0.1.0' },\n cwd: path.join(__dirname, 'fixtures'),\n });\n const git = simpleGit(fakeCwd);\n\n await git.init();\n\n // All is the default execpt `[commit] gpgsign`,\n // because i'm using it on my machine\n const localGitConfig = dedent`[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n [commit]\n gpgsign = false`;\n\n await fs.writeFile(path.join(fakeCwd, '.git', 'config'), localGitConfig);\n\n await git.add('./*');\n await git.commit('feat: initial blank release');\n await git.addTag('v0.1.0');\n\n await fs.writeFile(path.join(fakeCwd, 'foobar.txt'), 'zzzzz');\n await git.add('./*');\n await git.commit('feat: implement');\n\n await fs.writeFile(path.join(fakeCwd, 'fix.txt'), 'fixfix');\n await git.add('./*');\n await git.commit('fix: foo bar baz');\n\n await fs.writeFile(path.join(fakeCwd, 'fix2.txt'), '222xasas');\n await git.add('./*');\n await git.commit('fix: fo222222o bar baz');\n\n await fs.writeFile(path.join(fakeCwd, 'chore.txt'), 'chore');\n await git.add('./*');\n await git.commit('chore: foo bar baz');\n\n const result = await gitCommitsSince({\n name: '@tunnckocore/qq5',\n cwd: fakeCwd,\n });\n\n t.ok(result.pkg);\n t.ok(result.minor);\n t.ok(result.patch);\n t.strictEqual(result.increment, 'minor');\n t.strictEqual(result.minor.length, 1);\n t.strictEqual(result.patch.length, 2);\n t.strictEqual(result.pkg.name, '@tunnckocore/qq5');\n t.strictEqual(result.from, 'v0.1.0');\n t.strictEqual(result.to, '@');\n t.strictEqual(result.lastVersion, '0.1.0');\n t.strictEqual(result.nextVersion, '0.2.0');\n\n await git.addTag(`v${result.nextVersion}`);\n\n await fs.writeFile(path.join(fakeCwd, 'breaking.txt'), 'breaking breaking');\n await git.add('./*');\n await git.commit('feat(api): awful change\\n\\nBREAKING CHANGE: yeah!');\n\n const res = await gitCommitsSince({\n cwd: fakeCwd,\n });\n\n t.ok(res.commits);\n t.ok(Array.isArray(res.commits));\n t.strictEqual(res.commits[0].increment, 'major');\n\n await fs.remove(fakeCwd);\n}","title":"basic test"}} \ No newline at end of file +{"basic test":{"skip":false,"todo":false,"run":false,"isPending":false,"isRejected":false,"isFulfilled":true,"id":1,"str":"async (t) => {\n const fakeCwd = path.join(__dirname, 'fixtures', 'qq5');\n await fs.remove(fakeCwd);\n await charlike({\n project: { name: 'qq5' },\n locals: { version: '0.1.0' },\n cwd: path.join(__dirname, 'fixtures'),\n });\n const git = simpleGit(fakeCwd);\n\n await git.init();\n\n // All is the default execpt `[commit] gpgsign`,\n // because i'm using it on my machine\n const localGitConfig = dedent`[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n [user]\n name = Foo Bar Baz\n email = foobar@example.com\n [commit]\n gpgsign = false`;\n\n await fs.writeFile(path.join(fakeCwd, '.git', 'config'), localGitConfig);\n\n await git.add('./*');\n await git.commit('feat: initial blank release');\n await git.addTag('v0.1.0');\n\n await fs.writeFile(path.join(fakeCwd, 'foobar.txt'), 'zzzzz');\n await git.add('./*');\n await git.commit('feat: implement');\n\n await fs.writeFile(path.join(fakeCwd, 'fix.txt'), 'fixfix');\n await git.add('./*');\n await git.commit('fix: foo bar baz');\n\n await fs.writeFile(path.join(fakeCwd, 'fix2.txt'), '222xasas');\n await git.add('./*');\n await git.commit('fix: fo222222o bar baz');\n\n await fs.writeFile(path.join(fakeCwd, 'chore.txt'), 'chore');\n await git.add('./*');\n await git.commit('chore: foo bar baz');\n\n const result = await gitCommitsSince({\n name: '@tunnckocore/qq5',\n cwd: fakeCwd,\n });\n\n t.ok(result.pkg);\n t.ok(result.minor);\n t.ok(result.patch);\n t.strictEqual(result.increment, 'minor');\n t.strictEqual(result.minor.length, 1);\n t.strictEqual(result.patch.length, 2);\n t.strictEqual(result.pkg.name, '@tunnckocore/qq5');\n t.strictEqual(result.from, 'v0.1.0');\n t.strictEqual(result.to, '@');\n t.strictEqual(result.lastVersion, '0.1.0');\n t.strictEqual(result.nextVersion, '0.2.0');\n\n await git.addTag(`v${result.nextVersion}`);\n\n await fs.writeFile(path.join(fakeCwd, 'breaking.txt'), 'breaking breaking');\n await git.add('./*');\n await git.commit('feat(api): awful change\\n\\nBREAKING CHANGE: yeah!');\n\n const res = await gitCommitsSince({\n cwd: fakeCwd,\n });\n\n t.ok(res.commits);\n t.ok(Array.isArray(res.commits));\n t.strictEqual(res.commits[0].increment, 'major');\n\n await fs.remove(fakeCwd);\n}","title":"basic test"}} \ No newline at end of file