-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(git): ✨check remote differ to info users to pull first; check lo…
…cal status to decide i
- Loading branch information
Showing
14 changed files
with
182 additions
and
54 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @since 2016-11-27 14:28 | ||
* @author vivaxy | ||
*/ | ||
|
||
import sh from 'shelljs'; | ||
|
||
import * as console from '../../lib/console'; | ||
|
||
export default () => { | ||
const addCommand = `git add .`; | ||
console.info(addCommand); | ||
sh.exec(addCommand); | ||
}; |
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,14 @@ | ||
/** | ||
* @since 2016-11-27 14:28 | ||
* @author vivaxy | ||
*/ | ||
|
||
import sh from 'shelljs'; | ||
|
||
import * as console from '../../lib/console'; | ||
|
||
export default (commitMessage) => { | ||
const commitCommand = `git commit -m "${commitMessage}"`; | ||
console.info(commitCommand); | ||
sh.exec(commitCommand); | ||
}; |
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,25 @@ | ||
/** | ||
* @since 2016-11-22 21:20 | ||
* @author vivaxy | ||
*/ | ||
|
||
import sh from 'shelljs'; | ||
|
||
import * as console from '../../lib/console'; | ||
import gitRemote from '../status/gitRemote'; | ||
import gitBranch from '../status/gitBranch'; | ||
import getGitRemoteDiffer from '../status/getGitRemoteDiffer'; | ||
|
||
export default () => { | ||
// do not push when remove not exists | ||
if (gitRemote) { | ||
|
||
if (getGitRemoteDiffer()) { | ||
throw new Error(`remote differ, please pull changes`); | ||
} | ||
|
||
const pushCommand = `git push ${gitRemote} ${gitBranch} --tag`; | ||
console.info(pushCommand); | ||
sh.exec(pushCommand); | ||
} | ||
}; |
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,10 @@ | ||
/** | ||
* @since 2016-11-27 14:52 | ||
* @author vivaxy | ||
*/ | ||
|
||
import getInfoFromShell from '../../lib/getInfoFromShell'; | ||
|
||
export default () => { | ||
return getInfoFromShell(`git rev-list --count --left-only @{u}...HEAD`) !== `0`; | ||
}; |
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,8 @@ | ||
/** | ||
* @since 2016-11-27 14:02 | ||
* @author vivaxy | ||
*/ | ||
|
||
import getInfoFromShell from '../../lib/getInfoFromShell'; | ||
|
||
export default getInfoFromShell(`git symbolic-ref --short HEAD`); |
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,8 @@ | ||
/** | ||
* @since 2016-11-27 13:49 | ||
* @author vivaxy | ||
*/ | ||
|
||
import getInfoFromShell from '../../lib/getInfoFromShell'; | ||
|
||
export default getInfoFromShell(`git status -s`) === ``; |
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,8 @@ | ||
/** | ||
* @since 2016-11-27 14:02 | ||
* @author vivaxy | ||
*/ | ||
|
||
import getInfoFromShell from '../../lib/getInfoFromShell'; | ||
|
||
export default getInfoFromShell(`git remote`); |
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,37 @@ | ||
/** | ||
* @since 2016-11-27 13:59 | ||
* @author vivaxy | ||
*/ | ||
|
||
import sh from 'shelljs'; | ||
|
||
import gitBranch from './gitBranch'; | ||
import gitRemote from './gitRemote'; | ||
|
||
const shellSilentConfig = { | ||
silent: true, | ||
}; | ||
|
||
const hasCommitInShell = (command) => { | ||
let result = true; | ||
const shellExec = sh.exec(command, shellSilentConfig); | ||
if (shellExec.code === 0) { | ||
const splitResult = shellExec.stdout.split(`\n\r`); | ||
if (splitResult[0] === ``) { | ||
result = false; | ||
} | ||
} | ||
return result; | ||
}; | ||
|
||
const needPush = () => { | ||
let result = true; | ||
if (!gitRemote) { | ||
result = false; | ||
} else { | ||
result = hasCommitInShell(`git log ${gitRemote}/${gitBranch}..${gitBranch} --pretty=format:%H`); | ||
} | ||
return result; | ||
}; | ||
|
||
export default needPush(); |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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