-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New commands, bug fixes and support for aliases #54
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5003296
Added parser for response returned by "git status -sb" command.
7a77110
Added support for aliases.
803c93c
Code style fixes.
a963d69
Introduced new command - "status". It is also available as "st".
76bdddf
Introduced "mgit diff" command.
e5fce50
Introduced new command - "mgit checkout".
82fc657
Fixed invalid docs.
1d34b3d
Simplified the promises flow. All errors during the command execution…
5df1a79
Simplified the code.
f15450d
Tests for "checkout" command.
4d143d9
Tests for "diff" command.
280912e
Tests for "status" command.
54ae9d7
CI Trigger.
92f66f6
Changed the way how the prefixes are compared in "gitStatusParser()" …
d95291a
Removed "packagesPrefix" option from CLI.
5e7d82e
Improved the README.
260452b
"gitStatusParser()" will not return staged files as modified too.
7917873
Code style: aligned to new version of Linter.
93ea184
Improved logs returned by "mgit checkout" command.
d6abe89
Added missing dependency.
Reinmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
/** | ||
* @param {Object} data | ||
* @param {Object} data.repository | ||
* @param {String} data.repository.branch Name of branch (or commit hash) saved in `mgit.json` file. | ||
* @returns {Promise} | ||
*/ | ||
execute( data ) { | ||
const execCommand = require( './exec' ); | ||
const checkoutCommand = `git checkout ${ data.repository.branch }`; | ||
|
||
return execCommand.execute( getExecData( checkoutCommand ) ) | ||
.then( execResponse => { | ||
execResponse.logs.info = execResponse.logs.info[ 0 ].split( '\n' ).slice( -1 ); | ||
|
||
return Promise.resolve( execResponse ); | ||
} ); | ||
|
||
function getExecData( command ) { | ||
return Object.assign( {}, data, { | ||
arguments: [ command ] | ||
} ); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const chalk = require( 'chalk' ); | ||
|
||
module.exports = { | ||
/** | ||
* @param {Object} data | ||
* @param {Array.<String>} data.arguments The rest of arguments provided by the user. These options will modify the `git diff` command. | ||
* @returns {Promise} | ||
*/ | ||
execute( data ) { | ||
const execCommand = require( './exec' ); | ||
const diffCommand = ( 'git diff --color ' + data.arguments.join( ' ' ) ).trim(); | ||
|
||
return execCommand.execute( getExecData( diffCommand ) ) | ||
.then( execResponse => { | ||
if ( !execResponse.logs.info.length ) { | ||
return Promise.resolve( {} ); | ||
} | ||
|
||
return Promise.resolve( { | ||
logs: execResponse.logs | ||
} ); | ||
} ); | ||
|
||
function getExecData( command ) { | ||
return Object.assign( {}, data, { | ||
arguments: [ command ] | ||
} ); | ||
} | ||
}, | ||
|
||
afterExecute() { | ||
console.log( chalk.blue.italic( 'Logs are displayed from repositories which contain any change.' ) ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,29 +18,22 @@ module.exports = { | |
const log = require( '../utils/log' )(); | ||
const execCommand = require( './exec' ); | ||
|
||
return new Promise( ( resolve, reject ) => { | ||
execCommand.execute( getExecData( 'git rev-parse HEAD' ) ) | ||
.then( execResponse => { | ||
const commitHash = execResponse.logs.info[ 0 ]; | ||
return execCommand.execute( getExecData( 'git rev-parse HEAD' ) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same question as about |
||
.then( execResponse => { | ||
const commitHash = execResponse.logs.info[ 0 ]; | ||
|
||
const commandResponse = { | ||
packageName: data.packageName, | ||
commit: commitHash.slice( 0, 7 ) // Short version of the commit hash. | ||
}; | ||
const commandResponse = { | ||
packageName: data.packageName, | ||
commit: commitHash.slice( 0, 7 ) // Short version of the commit hash. | ||
}; | ||
|
||
log.info( `Commit: "${ commitHash }".` ); | ||
log.info( `Commit: "${ commitHash }".` ); | ||
|
||
resolve( { | ||
response: commandResponse, | ||
logs: log.all() | ||
} ); | ||
} ) | ||
.catch( error => { | ||
log.error( error ); | ||
|
||
reject( { logs: log.all() } ); | ||
return Promise.resolve( { | ||
response: commandResponse, | ||
logs: log.all() | ||
} ); | ||
} ); | ||
} ); | ||
|
||
function getExecData( command ) { | ||
return Object.assign( {}, data, { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you change anything in this file or is it just a code style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so – why changing anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in
bootstrap
,savehashes
andupdate
will resolve #45 and #49.