Skip to content

Commit 4a2a33f

Browse files
authored
Merge pull request #106 from cksource/t/85
Other: RIP mgit2 💀 Long live mrgit 🎉 Closes #85. BREAKING CHANGE: mgit2 was renamed to mrgit.
2 parents 2d1450c + ad3acc1 commit 4a2a33f

36 files changed

+351
-354
lines changed

README.md

Lines changed: 65 additions & 67 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
const chalk = require( 'chalk' );
1111
const meow = require( 'meow' );
12-
const mgit = require( './lib/index' );
12+
const mrgit = require( './lib/index' );
1313
const getCommandInstance = require( './lib/utils/getcommandinstance' );
1414

1515
handleCli();
@@ -33,15 +33,15 @@ function handleCli() {
3333
}
3434
};
3535

36-
const mgitLogo = `
37-
_ _
38-
(_) |
39-
_ __ ___ __ _ _| |_
40-
| '_ \` _ \\ / _\` | | __|
41-
| | | | | | (_| | | |_
42-
|_| |_| |_|\\__, |_|\\__|
43-
__/ |
44-
|___/
36+
const logo = `
37+
_ _
38+
(_) |
39+
_ __ ___ _ __ __ _ _| |_
40+
| '_ \` _ \\| '__| / _\` | | __|
41+
| | | | | | | _ | (_| | | |_
42+
|_| |_| |_|_|(_) \\__, |_|\\__|
43+
__/ |
44+
|___/
4545
`;
4646

4747
const {
@@ -52,20 +52,20 @@ function handleCli() {
5252
yellow: y,
5353
} = chalk;
5454

55-
const cli = meow( `${ mgitLogo }
55+
const cli = meow( `${ logo }
5656
${ u( 'Usage:' ) }
57-
$ mgit ${ c( 'command' ) } ${ y( '[--options]' ) } -- ${ m( '[--git-options]' ) }
57+
$ mrgit ${ c( 'command' ) } ${ y( '[--options]' ) } -- ${ m( '[--git-options]' ) }
5858
5959
${ u( 'Commands:' ) }
6060
${ c( 'checkout' ) } Changes branches in repositories according to the configuration file.
6161
${ c( 'close' ) } Merges specified branch with the current one and remove merged branch from the remote.
62-
${ c( 'commit' ) } Commits all changes. A shorthand for "mgit exec 'git commit -a'".
62+
${ c( 'commit' ) } Commits all changes. A shorthand for "mrgit exec 'git commit -a'".
6363
${ c( 'diff' ) } Prints changes from packages where something has changed.
6464
${ c( 'exec' ) } Executes shell command in each package.
6565
${ c( 'fetch' ) } Fetches existing repositories.
6666
${ c( 'pull' ) } Pulls changes in existing repositories.
6767
${ c( 'push' ) } Pushes changes in existing repositories to remotes.
68-
${ c( 'save' ) } Saves hashes of packages in mgit.json. It allows to easily fix project to a specific state.
68+
${ c( 'save' ) } Saves hashes of packages in mrgit.json. It allows to easily fix project to a specific state.
6969
${ c( 'status' ) } Prints a table which contains useful information about the status of repositories.
7070
${ c( 'sync' ) } Updates packages to the latest versions or install missing ones.
7171
@@ -77,7 +77,7 @@ function handleCli() {
7777
${ y( '--hash' ) } Whether to save current commit hashes. Used only by "${ u( 'save' ) }" command.
7878
7979
${ y( '--ignore' ) } Ignores packages which names match the given glob pattern. E.g.:
80-
${ g( '> mgit exec --ignore="foo*" "git status"' ) }
80+
${ g( '> mrgit exec --ignore="foo*" "git status"' ) }
8181
8282
Will ignore all packages which names start from "foo".
8383
${ g( 'Default: null' ) }
@@ -91,7 +91,7 @@ function handleCli() {
9191
${ y( '--recursive' ) } Whether to install dependencies recursively. Used only by "${ u( 'sync' ) }" command.
9292
9393
${ y( '--resolver-path' ) } Path to a custom repository resolver function.
94-
${ g( 'Default: \'@mgit2/lib/default-resolver.js\'' ) }
94+
${ g( 'Default: \'@mrgit/lib/default-resolver.js\'' ) }
9595
9696
${ y( '--resolver-url-template' ) } Template used to generate repository URL out of a
9797
simplified 'organization/repository' format of the dependencies option.
@@ -108,26 +108,26 @@ function handleCli() {
108108
whether the repository will be cloned to packages/@scope/pkgname' or 'packages/pkgname'.
109109
${ g( 'Default: \'git\'' ) }
110110
111-
${ y( '--resolver-default-branch' ) } The branch name to use if not specified in mgit.json dependencies.
111+
${ y( '--resolver-default-branch' ) } The branch name to use if not specified in mrgit.json dependencies.
112112
${ g( 'Default: master' ) }
113113
114114
${ y( '--scope' ) } Restricts the command to packages which names match the given glob pattern.
115115
${ g( 'Default: null' ) }
116116
117117
${ u( 'Git Options:' ) }
118118
Git options are supported by the following commands: commit, diff, fetch, push.
119-
Type "mgit [command] -h" in order to see which options are supported.
119+
Type "mrgit [command] -h" in order to see which options are supported.
120120
`, meowOptions );
121121

122122
const commandName = cli.input[ 0 ];
123123

124124
// If user specified a command and `--help` flag wasn't active.
125125
if ( commandName && !cli.flags.help ) {
126-
return mgit( cli.input, cli.flags );
126+
return mrgit( cli.input, cli.flags );
127127
}
128128

129129
// A user wants to see "help" screen.
130-
// Missing command. Displays help screen for the entire Mgit.
130+
// Missing command. Displays help screen for the entire Mr. Git.
131131
if ( !commandName ) {
132132
return cli.showHelp( 0 );
133133
}
@@ -141,7 +141,7 @@ function handleCli() {
141141
}
142142

143143
// Specified command is is available, displays the command's help.
144-
console.log( mgitLogo );
144+
console.log( logo );
145145
console.log( ` ${ u( 'Command:' ) } ${ c( commandInstance.name || commandName ) } ` );
146146
console.log( commandInstance.helpMessage );
147147
}

lib/commands/checkout.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ module.exports = {
2121

2222
return `
2323
${ u( 'Description:' ) }
24-
Checks out the repository to specified branch or commit saved in "mgit.json" file.
24+
Checks out the repository to specified branch or commit saved in "mrgit.json" file.
2525
26-
If specified a branch as an argument for "checkout" command, mgit will use the branch
27-
instead of data saved in "mgit.json". E.g "${ g( 'mgit checkout master' ) }" will check out
26+
If specified a branch as an argument for "checkout" command, mrgit will use the branch
27+
instead of data saved in "mrgit.json". E.g "${ g( 'mrgit checkout master' ) }" will check out
2828
all branches to "master".
2929
30-
You can also call "${ g( 'mgit checkout .' ) }" in order to restore files before changes.
30+
You can also call "${ g( 'mrgit checkout .' ) }" in order to restore files before changes.
3131
3232
${ u( 'Options:' ) }
33-
${ y( '--branch' ) } (-b) If specified, mgit will create given branch in all repositories
33+
${ y( '--branch' ) } (-b) If specified, mrgit will create given branch in all repositories
3434
that contain changes that could be committed.
35-
${ g( '> mgit checkout --branch develop' ) }
35+
${ g( '> mrgit checkout --branch develop' ) }
3636
`;
3737
},
3838

@@ -42,8 +42,8 @@ module.exports = {
4242
*/
4343
execute( data ) {
4444
// Used `--branch` option.
45-
if ( data.mgitOptions.branch ) {
46-
return this._createAndCheckout( data.mgitOptions.branch, data );
45+
if ( data.toolOptions.branch ) {
46+
return this._createAndCheckout( data.toolOptions.branch, data );
4747
}
4848

4949
const branch = data.arguments[ 0 ] || data.repository.branch;

lib/commands/close.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ module.exports = {
3131
${ u( 'Options:' ) }
3232
${ m( '--message' ) } (-m) An additional description for merge commit. It will be
3333
appended to the default message. E.g.:
34-
${ g( '> mgit merge develop -- -m "Some description about merged changes."' ) }
34+
${ g( '> mrgit merge develop -- -m "Some description about merged changes."' ) }
3535
`;
3636
},
3737

3838
beforeExecute( args ) {
3939
if ( !args[ 1 ] ) {
40-
throw new Error( 'Missing branch to merge. Use: mgit close [branch].' );
40+
throw new Error( 'Missing branch to merge. Use: mrgit close [branch].' );
4141
}
4242
},
4343

@@ -62,7 +62,7 @@ module.exports = {
6262
};
6363
}
6464

65-
const mergeMessage = this._getMergeMessage( data.mgitOptions, data.arguments );
65+
const mergeMessage = this._getMergeMessage( data.toolOptions, data.arguments );
6666
const commitTitle = `Merge branch '${ branch }'`;
6767

6868
let mergeCommand = `git merge ${ branch } --no-ff -m "${ commitTitle }"`;
@@ -100,17 +100,17 @@ module.exports = {
100100

101101
/**
102102
* @private
103-
* @param {options} mgitOptions Options resolved by mgit.
103+
* @param {options} toolOptions Options resolved by mrgit.
104104
* @param {Array.<String>>} argv List of arguments provided by the user via CLI.
105105
* @returns {Array.<String>}
106106
*/
107-
_getMergeMessage( mgitOptions, argv ) {
107+
_getMergeMessage( toolOptions, argv ) {
108108
const cliOptions = this._parseArguments( argv );
109109

110110
let message;
111111

112-
if ( mgitOptions.message ) {
113-
message = mgitOptions.message;
112+
if ( toolOptions.message ) {
113+
message = toolOptions.message;
114114
} else if ( cliOptions.message ) {
115115
message = cliOptions.message;
116116
} else {

lib/commands/commit.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ module.exports = {
2525
return `
2626
${ u( 'Description:' ) }
2727
Makes a commit in every repository that contains tracked files that have changed.
28-
This command is a shorthand for: "${ i( 'mgit exec \'git commit -a\'' ) }".
28+
This command is a shorthand for: "${ i( 'mrgit exec \'git commit -a\'' ) }".
2929
3030
${ u( 'Options:' ) }
3131
${ y( '--message' ) } (-m) Required. A message for the commit. It can be specified more then once, e.g.:
32-
${ g( '> mgit commit --message "Title of the commit." --message "Additional description."' ) }
32+
${ g( '> mrgit commit --message "Title of the commit." --message "Additional description."' ) }
3333
3434
${ u( 'Git Options:' ) }
3535
${ m( '--no-verify' ) } (-n) Whether to skip pre-commit and commit-msg hooks.
36-
${ g( '> mgit commit -m "Title of the commit." -- -n' ) }
36+
${ g( '> mrgit commit -m "Title of the commit." -- -n' ) }
3737
`;
3838
},
3939

4040
/**
4141
* @param {Array.<String>} args Arguments and options that a user provided calling the command.
42-
* @param {Options} mgitOptions Options resolved by mgit.
42+
* @param {Options} toolOptions Options resolved by mrgit.
4343
*/
44-
beforeExecute( args, mgitOptions ) {
44+
beforeExecute( args, toolOptions ) {
4545
const cliOptions = this._parseArguments( args );
46-
const commitMessage = this._getCommitMessage( mgitOptions, cliOptions );
46+
const commitMessage = this._getCommitMessage( toolOptions, cliOptions );
4747

4848
if ( !commitMessage.length ) {
49-
throw new Error( 'Missing --message (-m) option. Call "mgit commit -h" in order to read more.' );
49+
throw new Error( 'Missing --message (-m) option. Call "mrgit commit -h" in order to read more.' );
5050
}
5151
},
5252

@@ -71,7 +71,7 @@ module.exports = {
7171
}
7272

7373
const cliOptions = this._parseArguments( data.arguments );
74-
const commitCommand = this._buildCliCommand( data.mgitOptions, cliOptions );
74+
const commitCommand = this._buildCliCommand( data.toolOptions, cliOptions );
7575

7676
return execCommand.execute( getExecData( commitCommand ) );
7777
} );
@@ -85,12 +85,12 @@ module.exports = {
8585

8686
/**
8787
* @private
88-
* @param {options} mgitOptions Options resolved by mgit.
88+
* @param {options} toolOptions Options resolved by mrgit.
8989
* @param {Object} cliOptions Parsed arguments provided by the user via CLI.
9090
* @returns {String}
9191
*/
92-
_buildCliCommand( mgitOptions, cliOptions ) {
93-
const commitMessage = this._getCommitMessage( mgitOptions, cliOptions );
92+
_buildCliCommand( toolOptions, cliOptions ) {
93+
const commitMessage = this._getCommitMessage( toolOptions, cliOptions );
9494
let command = 'git commit -a';
9595

9696
command += ' ' + commitMessage.map( message => `-m "${ message }"` ).join( ' ' );
@@ -104,15 +104,15 @@ module.exports = {
104104

105105
/**
106106
* @private
107-
* @param {Options} mgitOptions Options resolved by mgit.
107+
* @param {Options} toolOptions Options resolved by mrgit.
108108
* @param {Object} cliOptions Parsed arguments provided by the user via CLI.
109109
* @returns {Array.<String>}
110110
*/
111-
_getCommitMessage( mgitOptions, cliOptions ) {
111+
_getCommitMessage( toolOptions, cliOptions ) {
112112
let message;
113113

114-
if ( mgitOptions.message ) {
115-
message = mgitOptions.message;
114+
if ( toolOptions.message ) {
115+
message = toolOptions.message;
116116
} else if ( cliOptions.message ) {
117117
message = cliOptions.message;
118118
} else {

lib/commands/diff.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ module.exports = {
2424
"${ m( '--color' ) }" is adding. You can cancel it using option "${ m( '--no-color' ) }".
2525
2626
${ u( 'Git Options:' ) }
27-
All options accepted by "${ i( 'git diff' ) }" are supported by mgit. Everything specified after "--" is passed directly to the
27+
All options accepted by "${ i( 'git diff' ) }" are supported by mrgit. Everything specified after "--" is passed directly to the
2828
"${ i( 'git diff' ) }" command.
2929
30-
E.g.: "${ g( 'mgit diff -- origin/master..master' ) }" will execute "${ i( 'git diff --color origin/master..master' ) }"
30+
E.g.: "${ g( 'mrgit diff -- origin/master..master' ) }" will execute "${ i( 'git diff --color origin/master..master' ) }"
3131
`;
3232
},
3333

lib/commands/exec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ module.exports = {
2020

2121
return `
2222
${ u( 'Description:' ) }
23-
Requires a command that will be executed on all repositories. E.g. "${ g( 'mgit exec pwd' ) }" will execute "${ i( 'pwd' ) }"
23+
Requires a command that will be executed on all repositories. E.g. "${ g( 'mrgit exec pwd' ) }" will execute "${ i( 'pwd' ) }"
2424
command in every repository. Commands that contain spaces must be wrapped in quotation marks,
25-
e.g.: "${ g( 'mgit exec "git remote"' ) }".
25+
e.g.: "${ g( 'mrgit exec "git remote"' ) }".
2626
`;
2727
},
2828

2929
/**
30-
* @param {Array.<String>} args Arguments that user provided calling the mgit.
30+
* @param {Array.<String>} args Arguments that user provided calling the mrgit.
3131
*/
3232
beforeExecute( args ) {
3333
if ( args.length === 1 ) {
34-
throw new Error( 'Missing command to execute. Use: mgit exec [command-to-execute].' );
34+
throw new Error( 'Missing command to execute. Use: mrgit exec [command-to-execute].' );
3535
}
3636
},
3737

@@ -43,11 +43,11 @@ module.exports = {
4343
const log = require( '../utils/log' )();
4444

4545
return new Promise( ( resolve, reject ) => {
46-
const newCwd = path.join( data.mgitOptions.packages, data.repository.directory );
46+
const newCwd = path.join( data.toolOptions.packages, data.repository.directory );
4747

4848
// Package does not exist.
4949
if ( !fs.existsSync( newCwd ) ) {
50-
log.error( `Package "${ data.packageName }" is not available. Run "mgit sync" in order to download the package.` );
50+
log.error( `Package "${ data.packageName }" is not available. Run "mrgit sync" in order to download the package.` );
5151

5252
return reject( { logs: log.all() } );
5353
}
@@ -56,14 +56,14 @@ module.exports = {
5656

5757
shell( data.arguments[ 0 ] )
5858
.then( stdout => {
59-
process.chdir( data.mgitOptions.cwd );
59+
process.chdir( data.toolOptions.cwd );
6060

6161
log.info( stdout );
6262

6363
resolve( { logs: log.all() } );
6464
} )
6565
.catch( error => {
66-
process.chdir( data.mgitOptions.cwd );
66+
process.chdir( data.toolOptions.cwd );
6767

6868
log.error( error );
6969

lib/commands/fetch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
return `
2626
${ u( 'Description:' ) }
2727
Download objects and refs from the remote repository. If some package is missed, the command will not be executed.
28-
For cloned repositories this command is a shorthand for: "${ i( 'mgit exec \'git fetch\'' ) }".
28+
For cloned repositories this command is a shorthand for: "${ i( 'mrgit exec \'git fetch\'' ) }".
2929
3030
${ u( 'Git Options:' ) }
3131
${ m( '--prune' ) } (-p) Before fetching, remove any remote-tracking references that
@@ -42,7 +42,7 @@ module.exports = {
4242
const log = require( '../utils/log' )();
4343
const execCommand = require( './exec' );
4444

45-
const destinationPath = path.join( data.mgitOptions.packages, data.repository.directory );
45+
const destinationPath = path.join( data.toolOptions.packages, data.repository.directory );
4646

4747
// Package is not cloned.
4848
if ( !fs.existsSync( destinationPath ) ) {

lib/commands/pull.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
return `
2222
${ u( 'Description:' ) }
2323
Pull changes in all packages. If some package is missed, the command will not be executed.
24-
For cloned repositories this command is a shorthand for: "${ i( 'mgit exec \'git pull\'' ) }".
24+
For cloned repositories this command is a shorthand for: "${ i( 'mrgit exec \'git pull\'' ) }".
2525
`;
2626
},
2727

@@ -32,7 +32,7 @@ module.exports = {
3232
execute( data ) {
3333
const execCommand = require( './exec' );
3434

35-
const destinationPath = path.join( data.mgitOptions.packages, data.repository.directory );
35+
const destinationPath = path.join( data.toolOptions.packages, data.repository.directory );
3636

3737
// Package is not cloned.
3838
if ( !fs.existsSync( destinationPath ) ) {

0 commit comments

Comments
 (0)