import { exec as gitExec } from "gulp-git" ; import { workspaceConfig as config } from "./config" ; const src = config . get ( "source.input" ) . join ( " " ) ; export const exec = ( { args } ) => new Promise ( ( res , rej ) => { const isSilent = ( process . env . ORADEW_SILENT || "true" ) === "true" ; gitExec ( { args , quiet : isSilent } , ( err , stdout ) => { if ( err ) { rej ( err ) ; } res ( stdout ) ; } ) ; } ) ; export const getChanges = ( ) => exec ( { args : `diff --name-only HEAD ${ src }` } ) ; export const getChangesStaged = ( ) => exec ( { args : `diff --name-only --staged ${ src }` } ) ; export const getChangesNotStaged = ( ) => exec ( { args : `diff --name-only ${ src } & git ls-files --others ${ src }` } ) ; export const getCommitedFilesSincePoint = ( from ) => exec ( { args : `log --diff-filter=ACMR --name-only --pretty="" ${ from }..head ${ src } ./scripts` , } ) ; export const getCommitedFilesByCommits = ( commits ) => exec ( { args : `show --diff-filter=ACMR --name-only --pretty="" ${ commits . join ( " " ) } ${ src } ./scripts` , } ) ; export const getFirstCommitOnBranch = ( ) => exec ( { args : `rev-list -1 --tags` , } ) ; export const cherryPickByGrepAndBranch = ( grep , branch ) => exec ( { args : `rev-list --reverse --grep=${ grep } ${ branch } | git cherry-pick -n --stdin` , } ) ; export const getStashedFiles = ( ) => exec ( { args : `stash show --name-only` } ) ; export const stash = ( ) => exec ( { args : `stash clear & git stash save --keep-index` } ) ; export const unstash = ( ) => exec ( { args : `add --all & git stash pop` } ) ; export const branch = ( branchName ) => exec ( { args : `checkout -b ${ branchName }` } ) ;