Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "gitpair", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"engines": { | ||
@@ -59,2 +59,3 @@ "node": ">=8" | ||
"babel-loader": "^8.0.5", | ||
"babel-plugin-source-map-support": "^2.0.1", | ||
"chalk": "^2.4.2", | ||
@@ -61,0 +62,0 @@ "clipboardy": "^2.0.0", |
154
README.md
@@ -6,7 +6,9 @@ <h1 align="center"> | ||
When pairing or doing mob programming on github projects, git does not allow us to commit with all the names of people who contributed. | ||
gitpair allows you to setup your team members and commit as normal. It then changes your commit based on the list of people referenced in the commit message. | ||
When pair programming or mob programming on git projects, there is a convention that allows us to document our co-authors in the commit message. | ||
However, adding the co-authorship information on every single commit is painful. | ||
Each author will randomly be credited with commiter or authorship, so that we can each be credited in our github contributions view ! | ||
Gitpair allows you to setup your team members and commit as normal. It then amends your commit to add your co-authors. | ||
Each author will randomly be credited either as the main author or one of the co-authors, so that we can each be credited in our github contributions view! | ||
### Before gitpair :sob: | ||
@@ -22,127 +24,77 @@ | ||
### Example: | ||
## Setup | ||
The following two commits | ||
First, install gitpair: | ||
```bash | ||
npm i -g gitpair | ||
``` | ||
$ commit -am "JBH|BDO|JON Added README file" | ||
``` | ||
Add all your co-authors in a .gitpair/authors.json file higher up in directory tree (e.g. user's home folder), for instance: | ||
```json | ||
[ | ||
{ | ||
"name": "Peter Yarrow", | ||
"email": "peter@ifihadahamm.er", | ||
"aliases": ["peter"] | ||
}, | ||
{ | ||
"name": "Paul Stookey", | ||
"email": "paul@tellitonthemonta.in", | ||
"aliases": ["paul"] | ||
}, | ||
{ | ||
"name": "Mary Travers", | ||
"email": "mary@lemontr.ee", | ||
"aliases": ["mary"] | ||
} | ||
] | ||
``` | ||
$ commit -am "@jordan @benoit @jonathan Added README file" | ||
``` | ||
are equivalent and will result in the following commit: | ||
## Add your pairs | ||
``` | ||
commit 5aac6c15b7ea2b8ed6b8daaba01539931b9d9309 | ||
Author: Jordan Bartholomew-Harrison, Benoit d'Oncieu and Jon McClennon <bdoncieu@gmail.com> | ||
AuthorDate: Thu Oct 27 22:09:34 2016 +0200 | ||
Commit: Jon McClennon <Jon.McClennon@gmail.com> | ||
CommitDate: Thu Oct 27 22:09:34 2016 +0200 | ||
Say you're doing some mob programming with Peter, Paul and Mary: | ||
BDO|JM: Added README file | ||
```bash | ||
gitpair with peter paul mary | ||
``` | ||
The _author's_ name contains the list of all author names while the _author_ and _committer_ emails will be _randomly_ choosen amongst the list of committers. The commit message is normalised as a pipe separated list of initials followed by a dash. | ||
Then commit your work | ||
## Installation | ||
``` | ||
$ commit -am "Too much of nothing" | ||
``` | ||
### Pre-requisites | ||
This will result in the following commit: | ||
A recent version of `node` and `npm`. | ||
``` | ||
Author: Mary Travers <mary@lemontr.ee> | ||
### Install | ||
Too much of nothing | ||
Co-authored-by: Paul Stookey <paul@tellitonthemonta.in> | ||
Co-authored-by: Benoit d'Oncieu <bdoncieu@gmail.com> | ||
Co-authored-by: Peter Yarrow <peter@ifihadahamm.er> | ||
``` | ||
$ npm install --save gitpair | ||
``` | ||
#### With [husky](https://github.com/typicode/husky) | ||
Every commit will randomly switch author and co-authors. | ||
Update your package.json to run the hook script: | ||
## Installation with husky | ||
```json | ||
{ | ||
... | ||
"scripts": { | ||
"postcommit": "$(npm bin)/gitpair hook" | ||
} | ||
} | ||
``` | ||
#### Manually adding the hook | ||
```bash | ||
$(npm bin)/gitpair install | ||
$ npm install --save-dev gitpair husky | ||
``` | ||
The installation adds a `post-commit` hook at the root of your project in the `.git/hooks` directory. | ||
Then update your package.json to run the hook script: | ||
### Configure | ||
Create a `.gitpair` file in your project or home folder: | ||
```json | ||
{ | ||
"team": [ | ||
{ "name": "Benoit d'Oncieu", "aliases": ["bdo", "benoit"], "email": "bdoncieu@gmail.com" }, | ||
{ | ||
"name": "Jon McClennon", | ||
"aliases": ["jm", "jon", "jonathan", "jonathanmcclennon"], | ||
"email": "Jon.McClennon@gmail.com" | ||
}, | ||
{ | ||
"name": "Jordan Bartholomew-Harrison", | ||
"aliases": ["jbh", "jordan", "jordanbharrison"], | ||
"email": "jordan.bh@outlook.com" | ||
... | ||
"husky": { | ||
"hooks" { | ||
"post-commit": "gitpair amend" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
In a project, you can get this file started by running: | ||
```bash | ||
$(npm bin)/gitpair init | ||
``` | ||
## Commit message patterns | ||
You can use one of two styles of commit messages. The user names used must correspond to one of the aliases you listed in your `.gitpair` file (see above). | ||
| Github styled | Initials | | ||
| ---------------------------- | ---------------------------- | | ||
| @bdo @jon Added package.json | BDO\|JON: Added package.json | | ||
Notes: | ||
- The normalised format message will use the `Initials` pattern and the first `alias` for each author. | ||
- When using the `Initials` flavor, the semicolon is optional. | ||
- When using the github styled initials, you can also specify users not in your team by tagging their github username. The git hook will ask if you want to add their info to your team. | ||
## Should I commit my .gitpair file into my repo? | ||
There are a few questions you need to ask yourself to answer this: | ||
- Is my repository private? | ||
- Should I be exposing email addresses in my repository (a more important question for public repositories)? | ||
- Will everyone working on this repository be pairing with the same people? | ||
If you answered no to any of these questions, then you likely want to have .gitpair in your local .gitignore. | ||
## Uninstall | ||
### Remove git hook | ||
```bash | ||
$(npm bin)/gitpair install -u | ||
``` | ||
### Removing the package | ||
``` | ||
$ npm uninstall gitpair | ||
``` | ||
This automatically removes the `post-commit` hook if it exists. |
@@ -0,0 +0,0 @@ import { bold } from 'chalk' |
@@ -0,0 +0,0 @@ import { bold, red, dim, reset } from 'chalk' |
@@ -0,0 +0,0 @@ export { default as with } from './with' |
@@ -0,0 +0,0 @@ import fs from 'fs' |
@@ -0,0 +0,0 @@ import fs from 'fs' |
@@ -0,0 +0,0 @@ import fs from 'fs' |
@@ -0,0 +0,0 @@ import { bold } from 'chalk' |
@@ -0,0 +0,0 @@ import fs from 'fs' |
import path from 'path' | ||
import fs from 'fs' | ||
import { homedir } from 'os' | ||
import { bold, red } from 'chalk' | ||
@@ -7,5 +8,15 @@ import closestPath from '../utils/closest-path' | ||
const authorsFilePath = path.join(GITPAIR_DIR, GITPAIR_AUTHORS_FILE) | ||
const authorsFile = closestPath(authorsFilePath) | ||
const findAuthorsFilePath = () => { | ||
const authorsFilePath = path.join(GITPAIR_DIR, GITPAIR_AUTHORS_FILE) | ||
const closest = closestPath(authorsFilePath) | ||
if (closest) { | ||
return closest | ||
} | ||
const homeDirectory = homedir() | ||
const homeAuthorsFilePath = path.join(homeDirectory, authorsFilePath) | ||
return fs.existsSync(homeAuthorsFilePath) && homeAuthorsFilePath | ||
} | ||
const authorsFile = findAuthorsFilePath() | ||
if (!authorsFile) { | ||
@@ -12,0 +23,0 @@ console.error(red(`Gitpair could not find the ${GITPAIR_AUTHORS_FILE} file!`)) |
@@ -0,0 +0,0 @@ import fs from 'fs' |
@@ -0,0 +0,0 @@ import path from 'path' |
@@ -0,0 +0,0 @@ import path from 'path' |
export const GITPAIR_DIR = '.gitpair' | ||
export const GITPAIR_AUTHORS_FILE = 'authors.json' | ||
export const GITPAIR_PAIRING_FILE = 'pairing.json' |
@@ -0,0 +0,0 @@ import { bold, red } from 'chalk' |
process.stdout.isTTY = false |
@@ -0,0 +0,0 @@ import fs from 'fs' |
import formatEmailAddress from './format-email-address' | ||
export default authors => authors.map(author => `Co-authored-by: ${formatEmailAddress(author)}`).join('\n') |
@@ -0,0 +0,0 @@ import { red } from 'chalk' |
export default ({ name, email }) => `${name} <${email}>` |
@@ -0,0 +0,0 @@ export default message => |
@@ -0,0 +0,0 @@ import { bold } from 'chalk' |
@@ -0,0 +0,0 @@ import niceJoin from './nice-join' |
@@ -0,0 +0,0 @@ import { execSync } from 'child_process' |
export default string => string.replace(/\n+co-authored-by:.*/gi, '') |
export default { | ||
target: 'node', | ||
devtool: 'inline-source-map', | ||
output: { | ||
@@ -4,0 +5,0 @@ libraryTarget: 'commonjs2', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
1693216
40
834
24
99
36