MCPcopy
hub / github.com/peter-evans/create-pull-request / commitsHaveDiff

Function commitsHaveDiff

src/create-or-update-branch.ts:129–151  ·  view source on GitHub ↗
(
  git: GitCommandManager,
  branch1: string,
  branch2: string,
  depth: number
)

Source from the content-addressed store, hash-verified

127
128// Return true if the specified number of commits on branch1 and branch2 have a diff
129async 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
153function splitLines(multilineString: string): string[] {
154 return multilineString

Callers 1

createOrUpdateBranchFunction · 0.85

Calls 1

execMethod · 0.80

Tested by

no test coverage detected