Skip to content

Commit db945eb

Browse files
authored
Merge pull request #17 from xnivaxhzne/master
Master -> Production
2 parents e0dd6aa + cc90869 commit db945eb

File tree

9 files changed

+84
-4
lines changed

9 files changed

+84
-4
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ npm i -g @xniva/git-shortcuts
3434
| `gma` | `git merge --abort` | Abort the merge |
3535
| `grb` | `git reset --${hardOrSoft} origin/$(git rev-parse --abbrev-ref HEAD)` | Reset the current branch to its remote equivalent |
3636
| `gphf` | `git push origin HEAD --force` | Force push the current branch |
37+
| `gc` | `git commit -m ${commitMessage}` | Commit the staged files with the give message |
38+
| `gcpm` | `gcm && gpm` | Checkout master and pull |
39+
| `gca` | `git commit -am ${commitMessage}` | Commit all the files with the give message |
3740

3841
### Master branch name is configurable:
3942

bin/git_add_commit_message.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env node
2+
import main from "../lib/git_add_commit_message/index.js";
3+
4+
main();

bin/git_checkout_pull_master.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env node
2+
import main from "../lib/git_checkout_pull_master/index.js";
3+
4+
main();

bin/git_commit_message.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env node
2+
import main from "../lib/git_commit_message/index.js";
3+
4+
main();

lib/git_add_commit_message/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import runCommand from "../utils/run_command.js";
2+
import inquirer from "inquirer";
3+
4+
const getCommitMessage = async () => {
5+
const inputFields = [
6+
{
7+
type: "input",
8+
name: "message",
9+
message: "Enter the commit message: ",
10+
},
11+
];
12+
13+
const { message } = await inquirer.prompt(inputFields);
14+
return message;
15+
};
16+
17+
const main = async () => {
18+
let commitMessage = process.argv.slice(2).join(" ");
19+
20+
if (!commitMessage) {
21+
commitMessage = await getCommitMessage();
22+
}
23+
24+
runCommand(`git add . && git commit -m "${commitMessage}"`);
25+
};
26+
27+
export default main;

lib/git_checkout_pull_master/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import runCommand from "../utils/run_command.js";
2+
3+
const main = () => {
4+
runCommand(`gcm`);
5+
runCommand(`gpm`);
6+
};
7+
8+
export default main;

lib/git_commit_message/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import runCommand from "../utils/run_command.js";
2+
import inquirer from "inquirer";
3+
4+
const getCommitMessage = async () => {
5+
const inputFields = [
6+
{
7+
type: "input",
8+
name: "message",
9+
message: "Enter the commit message: ",
10+
},
11+
];
12+
13+
const { message } = await inquirer.prompt(inputFields);
14+
return message;
15+
};
16+
17+
const main = async () => {
18+
let commitMessage = process.argv.slice(2).join(" ");
19+
20+
if (!commitMessage) {
21+
commitMessage = await getCommitMessage();
22+
}
23+
24+
runCommand(`git commit -m "${commitMessage}"`);
25+
};
26+
27+
export default main;

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xniva/git-shortcuts",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"description": "Shortcuts for the commonly used git commands",
55
"repository": "https://github.com/kavinkuma6/git-shortcuts",
66
"bin": {
@@ -20,7 +20,10 @@
2020
"gsf": "bin/git_see_feature_files.js",
2121
"gma": "bin/git_merge_abort.js",
2222
"grb": "bin/git_reset_current_branch.js",
23-
"gphf": "bin/git_push_head_force.js"
23+
"gphf": "bin/git_push_head_force.js",
24+
"gc": "bin/git_commit_message.js",
25+
"gca": "bin/git_add_commit_message.js",
26+
"gcpm": "bin/git_checkout_pull_master.js"
2427
},
2528
"author": "Kavinkumar R",
2629
"license": "MIT",

0 commit comments

Comments
 (0)