Skip to content

Commit

Permalink
Merge pull request #12 from jlegrone/feature/no-required-develop-branch
Browse files Browse the repository at this point in the history
New aliases + documentation
  • Loading branch information
jlegrone authored Oct 27, 2017
2 parents 39a4d95 + 6a15ab8 commit af52aa1
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 146 deletions.
62 changes: 0 additions & 62 deletions .cz-config.js

This file was deleted.

4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ install:
before_script:
- yarn build
script:
- if [[ $(node --version) == v4* ]];
then echo "Running node 4; skipping commitlint.";
else ./node_modules/.bin/commitlint --from="$TRAVIS_BRANCH" --to="$TRAVIS_COMMIT";
fi
- yarn install --production
- git aliases
- node lib/remove-config.test
Expand Down
8 changes: 8 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"generator-semantic-module": {
"packager": "yarn",
"semantic-release": false,
"commitizen-adapter": "cz-customizable",
"commitlint-config": "@commitlint/config-angular"
}
}
58 changes: 52 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ $ npm uninstall --global @jlegrone/git-config

# Usage

To view the source for each alias, see [src/jlegrone.gitconfig](src/jlegrone.gitconfig).
To view the source for an alias, type

<hr>
```bash
$ git help <alias>
```

## Available Aliases

#### `git aliases`

Expand All @@ -43,6 +47,9 @@ List all local and remote branches containing a given commit hash.

```bash
$ git contains 27395436382cd897fd957635bd42cf78788f11b1
* feature/add-docs
master
remotes/origin/master
```

<hr>
Expand All @@ -51,17 +58,17 @@ $ git contains 27395436382cd897fd957635bd42cf78788f11b1

Rebase the current branch onto `origin/develop`.

> Caution: This command rewrites history.
Rebases onto `origin/master` if no `develop` branch is present.

> Requires a `develop` branch.
> Caution: This command rewrites history.
<hr>

#### `git start <feature>`

Checkout a new branch based on `origin/develop`, prefixed with `feature`.

> Requires a `develop` branch.
Uses `origin/master` if no `develop` branch is present.

```bash
$ git start user-service
Expand Down Expand Up @@ -132,6 +139,8 @@ $ git reword 27395436382cd897fd957635bd42cf78788f11b1

Perform an interactive rebase starting from the specified commit.

> Accepts all options that can be passed to [git-rebase](https://git-scm.com/docs/git-rebase).
> Caution: This command rewrites history, and may introduce conflicts during rebase.
```bash
Expand All @@ -156,7 +165,9 @@ Remove the current branch from the remote `origin`.

Force push to the upstream branch, but receive a warning if new commits were added to the remote since your last checkout.

For more information, see http://weiqingtoh.github.io/force-with-lease/
For more information, see http://weiqingtoh.github.io/force-with-lease/.

> Accepts all options that can be passed to [git-push](https://git-scm.com/docs/git-push).
<hr>

Expand All @@ -170,7 +181,42 @@ Delete local branches that have been fully merged into `master` or `develop`.

Checkout a new branch. Shorthand for `git checkout -b <branch-name>`.

> Accepts all options that can be passed to [git-checkout](https://git-scm.com/docs/git-checkout).
```bash
$ git cb test/my-proof-of-concept
# now on branch test/my-proof-of-concept
```

<hr>

#### `git l`

Show an abridged `git log` output, with one line per commit.

> Accepts all options that can be passed to [git-log](https://git-scm.com/docs/git-log).
```bash
$ git l
6b1768a 2017-08-09 (tag: v1.3.3) Merge pull request #9 from jlegrone/feature/re-enable-release [GitHub]
1b0b519 2017-08-09 chore(travis): install dev dependencies again in post_success hook [Jacob LeGrone]
4b5cb73 2017-08-09 Merge pull request #8 from jlegrone/feature/fix-missing-dep [GitHub]
e5695bc 2017-08-09 fix(install): update to working validate-git-version [Jacob LeGrone]
3fab789 2017-08-09 test(travis): install production dependencies only [Jacob LeGrone]
...
```

<hr>

#### `git s`

Show an abridged `git status` output which only includes files changed.

> Accepts all options that can be passed to [git-status](https://git-scm.com/docs/git-status).
```bash
$ git s
M README.md
M commitizen.config.js
M src/jlegrone.gitconfig
```
83 changes: 83 additions & 0 deletions commitizen.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* eslint-env node */

const types = [
{
value: 'feat',
name: 'feat: A new feature'
},
{
value: 'fix',
name: 'fix: A bug fix'
},
{
value: 'docs',
name: 'docs: Documentation only changes'
},
{
value: 'style',
name: `style: Changes that do not affect the meaning of the code
(white-space, formatting, missing semi-colons, etc)`
},
{
value: 'refactor',
name: 'refactor: A code change that neither fixes a bug nor adds a feature'
},
{
value: 'perf',
name: 'perf: A code change that improves performance'
},
{
value: 'test',
name: 'test: Adding missing tests'
},
{
value: 'chore',
name: `chore: Changes to the build process or auxiliary tools
and libraries such as documentation generation`
},
{
value: 'revert',
name: 'revert: Revert to a commit'
}
];

const scopes = [
'aliases',
'branches',
'contains',
'up',
'start',
'hotfix',
'wip',
'undo',
'amend',
'fixup',
'reword',
'edit',
'publish',
'unpublish',
'pushf',
'cleanup',
'cb',
'log',
'status',
'branch-name',
'develop-branch'
].map(name => ({ name }));

module.exports = {
types,
scopes,
scopeOverrides: {
chore: [
{ name: 'npm' }
]
},
allowCustomScopes: true,
allowBreakingChanges: [
'feat',
'fix',
'perf',
'refactor'
]
};
21 changes: 21 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-env node */

const { types, scopes, allowCustomScopes } = require('./commitizen.config');

const validTypes = types.map((type) => type.value);
const validScopes = scopes.map((scope) => scope.name);
const scopeValidationLevel = allowCustomScopes ? 1 : 2;

module.exports = {
extends: ['@commitlint/config-angular'],

// Add your own rules. See http://marionebl.github.io/commitlint
rules: {
// Apply valid scopes and types
'scope-enum': [scopeValidationLevel, 'always', validScopes],
'type-enum': [2, 'always', validTypes],

// Disable language rule
lang: [0, 'always', 'eng']
}
};
41 changes: 8 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,31 @@
"prebuild": "rimraf lib",
"build": "babel scripts --out-dir lib",
"commit": "git-cz",
"commitmsg": "validate-commit-msg",
"commitmsg": "commitlint -e",
"postinstall": "node lib/bootstrap-config",
"prepublish": "npm run build",
"preuninstall": "node lib/remove-config",
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post"
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post",
"commit:retry": "git-cz --retry"
},
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
},
"cz-customizable": {
"config": ".cz-config.js"
},
"validate-commit-msg": {
"types": [
"feat",
"fix",
"docs",
"refactor",
"test",
"chore",
"revert"
],
"scope": {
"required": false,
"allowed": [
"aliases",
"repo",
"npm"
],
"validate": true,
"multiple": true
},
"warnOnFail": true,
"maxSubjectLength": 100,
"subjectPattern": ".+",
"subjectPatternErrorMsg": "subject does not match subject pattern!",
"helpMessage": "\nTry running `yarn commit` for help.",
"autoFix": true
"config": "commitizen.config.js"
}
},
"devDependencies": {
"@commitlint/cli": "^4.2.1",
"@commitlint/config-angular": "^4.2.1",
"babel-cli": "^6.24.1",
"babel-preset-env": "^1.6.0",
"commitizen": "^2.9.6",
"cz-customizable": "^5.0.0",
"cz-customizable": "^5.2.0",
"husky": "^0.14.3",
"rimraf": "^2.6.1",
"semantic-release": "^6.3.6",
"validate-commit-msg": "^2.12.2"
"semantic-release": "^6.3.6"
},
"dependencies": {
"chalk": "^2.1.0",
Expand Down
17 changes: 14 additions & 3 deletions src/jlegrone.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# Update your current branch from develop
# ** Rewrites history **
# Usage: git up
up = pull --rebase --autostash origin develop
up = "!git pull --rebase --autostash origin $(git develop-branch)"

# Start a feature branch based off of latest develop branch
# Usage: git start <name-of-feature>
start = "!sh -c \"git checkout develop && git pull && git cb feature/$1\" -"
start = "!sh -c \"git checkout $(git develop-branch) && git pull && git cb feature/$1\" -"

# Start a hotfix branch based off of latest master branch
# Usage: git hotfix <name-of-production-patch>
Expand Down Expand Up @@ -73,5 +73,16 @@
# Usage: git cb <branch-name>
cb = checkout -b

# Get the current branch name (not so useful in itself, but used in other aliases)
# Show an abridged git log output, one line per commit
# Usage: git l
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short

# Run git status with the short-format flag
# Usage: git s
s = status --short

# Get the current branch name (used in other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"

# Get the develop branch (used in other aliases)
develop-branch = "!(git show-ref --quiet refs/heads/develop && echo develop) || echo master"
Loading

0 comments on commit af52aa1

Please sign in to comment.