Skip to content

Commit

Permalink
major(release): optimize, add tests, local gitconfig in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
  • Loading branch information
Charlike Mike Reagent committed Nov 6, 2018
1 parent c8fdc7c commit d97be60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;

Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/index.snapshot.json
Original file line number Diff line number Diff line change
@@ -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"}}
{"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"}}

0 comments on commit d97be60

Please sign in to comment.