MCPcopy Index your code
hub / github.com/desktop/desktop / getDiffChangesCommitMessage

Method getDiffChangesCommitMessage

app/src/lib/api.ts:1978–2006  ·  view source on GitHub ↗

* Leverages Copilot to generate the commit details (title and description) * for a given diff. * * @param diff Diff of changes to be committed, in git format * @returns Commit details (title and description) generated by Copilot

(
    diff: string
  )

Source from the content-addressed store, hash-verified

1976 * @returns Commit details (title and description) generated by Copilot
1977 */
1978 public async getDiffChangesCommitMessage(
1979 diff: string
1980 ): Promise<ICopilotCommitMessage> {
1981 try {
1982 const response = await this.copilotRequest(
1983 '/agents/github-desktop-commit-message-generation',
1984 diff
1985 )
1986
1987 const choice = response.choices.at(0)
1988
1989 if (!choice) {
1990 throw new Error('No choice found in response')
1991 }
1992
1993 const message = choice.message.content
1994 if (!message) {
1995 throw new Error('No message found in response')
1996 }
1997
1998 return parseCopilotCommitMessage(message)
1999 } catch (e) {
2000 log.warn(
2001 `getDiffChangesCommitMessage: failed with endpoint ${this.endpoint}`,
2002 e
2003 )
2004 throw e
2005 }
2006 }
2007
2008 /**
2009 * Get the allowed poll interval for fetching. If an error occurs it will

Callers 2

api-test.tsFile · 0.80

Calls 3

copilotRequestMethod · 0.95
warnMethod · 0.80

Tested by

no test coverage detected