( git: GitCommandManager, branch1: string, branch2: string, depth: number )
| 127 | |
| 128 | // Return true if the specified number of commits on branch1 and branch2 have a diff |
| 129 | async function commitsHaveDiff( |
| 130 | git: GitCommandManager, |
| 131 | branch1: string, |
| 132 | branch2: string, |
| 133 | depth: number |
| 134 | ): Promise<boolean> { |
| 135 | // Some action use cases lead to the depth being a very large number and the diff fails. |
| 136 | // I've made this check optional for now because it was a fix for an edge case that is |
| 137 | // very rare, anyway. |
| 138 | try { |
| 139 | const diff1 = ( |
| 140 | await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`]) |
| 141 | ).stdout.trim() |
| 142 | const diff2 = ( |
| 143 | await git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`]) |
| 144 | ).stdout.trim() |
| 145 | return diff1 !== diff2 |
| 146 | } catch (error) { |
| 147 | core.info('Failed optional check of commits diff; Skipping.') |
| 148 | core.debug(utils.getErrorMessage(error)) |
| 149 | return false |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | function splitLines(multilineString: string): string[] { |
| 154 | return multilineString |
no test coverage detected