File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,12 @@ function main() {
105105 // add stage all changes
106106 execSync ( 'git add *' , { stdio : 'inherit' } ) ;
107107
108+ if ( ! hasChanges ( ) ) {
109+ console . log ( 'No changes, exiting' ) ;
110+
111+ return ;
112+ }
113+
108114 let commitmsg = commitMessage ;
109115 const githubSHA = process . env [ 'GITHUB_SHA' ] ;
110116
@@ -130,6 +136,26 @@ function main() {
130136
131137main ( ) ;
132138
139+ /**
140+ * Check if the current git repo has changes staged
141+ * @returns {boolean } `true` if there are changes staged, `false` otherwise
142+ */
143+ function hasChanges ( ) {
144+ try {
145+ // the following command exists with "0" if there are no changes, otherwise "1"
146+ execSync ( 'git diff-index --quiet HEAD --' ) ;
147+
148+ return false ;
149+ } catch ( err ) {
150+ // check if the error is a childprocess error, which will always have a "status" property
151+ if ( ! ! err . status ) {
152+ return true ;
153+ }
154+
155+ throw err ;
156+ }
157+ }
158+
133159/**
134160 * Generate the versions.json file
135161 * @returns Object with keys sorted so that "beta" is first and otherwise the highest number descending
You can’t perform that action at this time.
0 commit comments