Skip to content

Commit

Permalink
Merge pull request #38 from crazyfactory/37-soft-push
Browse files Browse the repository at this point in the history
37 soft push
  • Loading branch information
paibamboo authored Dec 3, 2019
2 parents ae67b7a + 9bb8643 commit 13d78b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ $ npm install -g @crazyfactory/gitflow

## Usages

### `$ gitflow alias <name> <cmd>`
Set `<cmd>` as an alias of `<name>` which you can run as `gitflow <name>`

### `$ gitflow set-config`
Set `project_name` and `sprint_number` for current path

Expand Down Expand Up @@ -51,3 +54,6 @@ Delete personal access token locally
- Push local branch to origin
- Create pull and fill content `Closes #{issue_number}` to `origin/master`
- Switch local branch to `origin/master`

### `$ gitflow soft-push`
- Create an empty commit and push it
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ program
}
});

program
.command('soft-push')
.description('Perform soft push to trigger CI build')
.action(async () => {
try {
await git.bailIfNotGitDirectory();
await git.softPush();
} catch (e) {
console.log(e.message);
}
});

program.on('command:*', async (args) => {
const alias = args.shift();
let cmd = conf.get(`alias:${alias}`);
Expand Down
7 changes: 7 additions & 0 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ async function doStash() {
await stash(stashLabel.replace(/"|'/g, ''));
}

async function softPush() {
await exec('git commit --allow-empty -m "chore(ci): trigger build"');

await exec('git push origin HEAD');
}

async function startFeature(config, featureBranch) {
await doStash();

Expand Down Expand Up @@ -325,6 +331,7 @@ module.exports = {
isGitDirectory,
bailIfNotGitDirectory,
setConfig,
softPush,
startFeature,
startHotfix,
startSprint
Expand Down

0 comments on commit 13d78b7

Please sign in to comment.