File tree Expand file tree Collapse file tree 4 files changed +36
-10
lines changed Expand file tree Collapse file tree 4 files changed +36
-10
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export async function pushGeneratedCode(): Promise<void> {
20
20
console . log ( `Checking codegen status on '${ baseBranch } '.` ) ;
21
21
22
22
const nbDiff = await getNbGitDiff ( {
23
- branch : baseBranch ,
23
+ branch : 'origin/generated/main' ,
24
24
head : null ,
25
25
path : FOLDERS_TO_CHECK ,
26
26
} ) ;
@@ -59,7 +59,7 @@ export async function pushGeneratedCode(): Promise<void> {
59
59
}
60
60
61
61
const commitMessage =
62
- await run ( `git show -s ${ baseBranch } --format="Generated code for commit %H.
62
+ await run ( `git show -s ${ baseBranch } --format="chore: generated code for commit %H.
63
63
64
64
Co-authored-by: %an <%ae>"` ) ;
65
65
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
} from '../../common' ;
14
14
import { getLanguageFolder } from '../../config' ;
15
15
import { cloneRepository , configureGitHubAuthor } from '../../release/common' ;
16
+ import { getNbGitDiff } from '../utils' ;
16
17
17
18
export function decideWhereToSpread ( commitMessage : string ) : string [ ] {
18
19
if ( commitMessage . startsWith ( 'chore: release' ) ) {
@@ -69,6 +70,16 @@ async function spreadGeneration(): Promise<void> {
69
70
await emptyDirExceptForDotGit ( tempGitDir ) ;
70
71
await copy ( clientPath , tempGitDir , { preserveTimestamps : true } ) ;
71
72
73
+ if (
74
+ ( await getNbGitDiff ( {
75
+ head : null ,
76
+ cwd : tempGitDir ,
77
+ } ) ) === 0
78
+ ) {
79
+ console . log ( `Skipping ${ lang } repository, because there is no change.` ) ;
80
+ return ;
81
+ }
82
+
72
83
await configureGitHubAuthor ( tempGitDir ) ;
73
84
await run ( `git add .` , { cwd : tempGitDir } ) ;
74
85
await gitCommit ( {
Original file line number Diff line number Diff line change @@ -2,22 +2,32 @@ import { run } from '../common';
2
2
3
3
/**
4
4
* Returns the number of diff between a `branch` and its `HEAD` for the given `path`.
5
- * Head defaults to `HEAD`, providing `null` will check unstaged changes.
5
+ *
6
+ * @param opts - Parameters of the method.
7
+ * @param opts.branch - The branch to trigger the operation, defaults to '' (current branch).
8
+ * @param opts.head - The head to compare the operation, defaults to 'HEAD', providing 'null' will check for unstaged changes.
9
+ * @param opts.path - The path to look for changes in, defaults to '.' (current directory).
10
+ * @param opts.cwd - The path to run the command, defaults to current directory.
6
11
*/
7
12
export async function getNbGitDiff ( {
8
- branch,
13
+ branch = '' ,
9
14
head = 'HEAD' ,
10
- path,
11
- } : {
15
+ path = '.' ,
16
+ cwd,
17
+ } : Partial < {
12
18
branch : string ;
13
- head ? : string | null ;
19
+ head : string | null ;
14
20
path : string ;
15
- } ) : Promise < number > {
21
+ cwd : string ;
22
+ } > ) : Promise < number > {
16
23
const checkHead = head === null ? '' : `...${ head } ` ;
17
24
18
25
return parseInt (
19
26
(
20
- await run ( `git diff --shortstat ${ branch } ${ checkHead } -- ${ path } | wc -l` )
27
+ await run (
28
+ `git diff --shortstat ${ branch } ${ checkHead } -- ${ path } | wc -l` ,
29
+ { cwd }
30
+ )
21
31
) . trim ( ) ,
22
32
10
23
33
) ;
Original file line number Diff line number Diff line change 2
2
import dotenv from 'dotenv' ;
3
3
import semver from 'semver' ;
4
4
5
+ import { getNbGitDiff } from '../ci/utils' ;
5
6
import {
6
7
LANGUAGES ,
7
8
ROOT_ENV_PATH ,
@@ -161,7 +162,11 @@ async function createReleaseIssue(): Promise<void> {
161
162
) ;
162
163
}
163
164
164
- if ( await run ( 'git status --porcelain' ) ) {
165
+ if (
166
+ ( await getNbGitDiff ( {
167
+ head : null ,
168
+ } ) ) !== 0
169
+ ) {
165
170
throw new Error (
166
171
'Working directory is not clean. Commit all the changes first.'
167
172
) ;
You can’t perform that action at this time.
0 commit comments