From 6e90d26e278e898cd282c4999eef09169b3e1b75 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:17:23 -0800 Subject: [PATCH 1/7] [wip] setup ci --- .gitignore | 2 ++ .npmignore | 5 +++++ .travis.yml | 3 +++ forge.js | 2 ++ package.json | 15 +++++++++++++++ test/forge.js | 0 6 files changed, 27 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 .travis.yml create mode 100644 package.json create mode 100644 test/forge.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5f19d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..217f4e9 --- /dev/null +++ b/.npmignore @@ -0,0 +1,5 @@ +node_modules +package-lock.json +spoof.sh +LICENSE +.travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c7b016c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - 12 diff --git a/forge.js b/forge.js index 17b9521..5b2b64b 100644 --- a/forge.js +++ b/forge.js @@ -1,3 +1,5 @@ +#!/usr/bin/env/node + const { promisify } = require('util'); const exec = promisify(require('child_process').exec); diff --git a/package.json b/package.json new file mode 100644 index 0000000..8fab840 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "git-schmear", + "version": "0.0.0", + "scripts": { + "test": "npm run test:unit && npm run test:lint", + "test:unit": "mocha test/*.js", + "test:lint": "echo looks good" + }, + "bin": { + "schmear": "./forge.js" + }, + "devDependencies": { + "mocha": "^6.2.2" + } +} diff --git a/test/forge.js b/test/forge.js new file mode 100644 index 0000000..e69de29 From 6aa7736fd1a6edd8adbb7bcfe8de221cab796b5b Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:21:48 -0800 Subject: [PATCH 2/7] [doc] add to readme --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d41a545..9dbd717 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,14 @@ If you want to spoof a fresh repo, copy over `spoof.sh` to get yourself some freshly minted commits. You can see [this](schmeared) repo for an example of a repo that has been `git-schmeared`. +## Testing ![](https://travis-ci.com/SivanMehta/git-schmear.svg?branch=master) + +``` +npm test +``` + ## TODO -- ~~literally any testing~~ - Variable intervals of schmear, as opposed to 1 day intervals. - Preserving `git` authorship, which is currently blown away. - Take start time as a CLI parameter and distribute commits from then until now. From 0b1801ce7373a10f26376a751d4180b581f415b4 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:39:40 -0800 Subject: [PATCH 3/7] [wip] basic test scaffold --- package.json | 9 ++++++--- forge.js => schmear.js | 7 +++++-- test/forge.js | 0 test/schmear.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) rename forge.js => schmear.js (97%) delete mode 100644 test/forge.js create mode 100644 test/schmear.js diff --git a/package.json b/package.json index 8fab840..ed7e0c8 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,12 @@ "test:lint": "echo looks good" }, "bin": { - "schmear": "./forge.js" + "schmear": "./schmear.js" }, "devDependencies": { - "mocha": "^6.2.2" - } + "mocha": "^6.2.2", + "proxyquire": "^2.1.3", + "sinon": "^7.5.0" + }, + "main": "schmear.js" } diff --git a/forge.js b/schmear.js similarity index 97% rename from forge.js rename to schmear.js index 5b2b64b..6a39d0d 100644 --- a/forge.js +++ b/schmear.js @@ -104,7 +104,10 @@ class Runner { } } -(async function () { +async function run () { const runner = new Runner(); await runner.start(); -})(); +} + +if(!module.parent) run(); +module.exports = Runner; diff --git a/test/forge.js b/test/forge.js deleted file mode 100644 index e69de29..0000000 diff --git a/test/schmear.js b/test/schmear.js new file mode 100644 index 0000000..30504ea --- /dev/null +++ b/test/schmear.js @@ -0,0 +1,31 @@ +const proxyquire = require('proxyquire'); + +function exec(cmd, cb) { + cb(null, { stdout: cmd }); +} + +describe('Commiting Forgery', function () { + let Runner; + beforeEach(function () { + const Schmear = proxyquire('../', { + 'child_process': ({ exec }) + }); + + Runner = new Schmear(); + }); + + it('exposes a class'); + it('formDay'); + + describe('buildStack', function () { + it('does some stuff'); + }); + + describe('rebuildRepo', function () { + it('does some stuff'); + }); + + describe('start', function () { + it('does some stuff'); + }); +}); From 20c60fa3a92fe3ff91d599fd2ac991e64f81df21 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:42:54 -0800 Subject: [PATCH 4/7] [wip] linting --- package.json | 6 +++++- schmear.js | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ed7e0c8..18f1362 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,16 @@ "scripts": { "test": "npm run test:unit && npm run test:lint", "test:unit": "mocha test/*.js", - "test:lint": "echo looks good" + "test:lint": "eslint-godaddy schmear.js" }, "bin": { "schmear": "./schmear.js" }, "devDependencies": { + "eslint": "^6.3.0", + "eslint-config-godaddy": "^4.0.0", + "eslint-plugin-json": "^1.4.0", + "eslint-plugin-mocha": "^6.1.0", "mocha": "^6.2.2", "proxyquire": "^2.1.3", "sinon": "^7.5.0" diff --git a/schmear.js b/schmear.js index 6a39d0d..0b8158d 100644 --- a/schmear.js +++ b/schmear.js @@ -12,7 +12,7 @@ const today = new Date(); * * @param {String} message - String of what the commit originally was * @param {String} day - When the commit "happened" - * @return {String} formatted `git commit` command + * @returns {String} formatted `git commit` command */ function formCommit(message, day) { return `GIT_COMMITTER_DATE="${day}" git commit -m "${message}" --date "${day}"`; @@ -66,7 +66,7 @@ class Runner { const message = lines.slice(0, lines.length - 2).join('\n'); // The first commit is a special case because we cannot `git reset`. - if (idx == 1) { + if (idx === 1) { await exec('git update-ref -d HEAD'); const day = this.formDay(0); const commit = formCommit(message, day); @@ -96,18 +96,18 @@ class Runner { const commit = formCommit(message, day); await exec(commit); - if(this.messageStack.length > 0) { + if (this.messageStack.length > 0) { const { stdout } = await exec('git stash list | wc -l'); - const completed = this.days - parseInt(stdout.match(/[0-9]+/)[0]); + const completed = this.days - parseInt(stdout.match(/[0-9]+/)[0], 10); await this.rebuildRepo(completed + 1); } } } -async function run () { +async function run() { const runner = new Runner(); await runner.start(); } -if(!module.parent) run(); +if (!module.parent) run(); module.exports = Runner; From a0da5cbdc0b4153c0db09c47ea6acb3f23981da9 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:47:45 -0800 Subject: [PATCH 5/7] [doc] the package's name --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 9dbd717..7f086ac 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,7 @@ minute. ## Running yourself ```sh -cd /repo/you/want/to/spoof/ -cp /path/to/this/repo/forge.js . -node forge.js +npm install -g git-schmear ``` If you want to spoof a fresh repo, copy over `spoof.sh` to get yourself some From fa7f2eb4f4aa51f758ec0c8c31ebc3f19709a320 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:51:15 -0800 Subject: [PATCH 6/7] [doc] don't publish test files --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index 217f4e9..be438b5 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,4 @@ package-lock.json spoof.sh LICENSE .travis.yml +test/ From 1013856f7e06ff26de214fc624335440b4ffa472 Mon Sep 17 00:00:00 2001 From: Sivan Mehta Date: Sun, 17 Nov 2019 15:52:22 -0800 Subject: [PATCH 7/7] [doc] add keywords --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.json b/package.json index 18f1362..ca0c33b 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,12 @@ "bin": { "schmear": "./schmear.js" }, + "keywords": [ + "git", + "schmear", + "spoof", + "time-travel" + ], "devDependencies": { "eslint": "^6.3.0", "eslint-config-godaddy": "^4.0.0",