@@ -17,6 +17,7 @@ import * as gitUtils from "./gitUtils";
1717import readChangesetState from "./readChangesetState" ;
1818import resolveFrom from "resolve-from" ;
1919import { throttling } from "@octokit/plugin-throttling" ;
20+ import { commitChangesFromRepo } from "@s0/ghcommit/git" ;
2021
2122// GitHub Issues/PRs messages have a max size limit on the
2223// message body payload.
@@ -334,9 +335,6 @@ export async function runVersion({
334335
335336 let { preState } = await readChangesetState ( cwd ) ;
336337
337- await gitUtils . switchToMaybeExistingBranch ( versionBranch ) ;
338- await gitUtils . reset ( github . context . sha ) ;
339-
340338 let versionsByDirectory = await getVersionsByDirectory ( cwd ) ;
341339
342340 if ( script ) {
@@ -377,16 +375,25 @@ export async function runVersion({
377375 ) ;
378376
379377 const finalPrTitle = `${ prTitle } ${ ! ! preState ? ` (${ preState . tag } )` : "" } ` ;
380-
381- // project with `commit: true` setting could have already committed files
382- if ( ! ( await gitUtils . checkIfClean ( ) ) ) {
383- const finalCommitMessage = `${ commitMessage } ${
384- ! ! preState ? ` (${ preState . tag } )` : ""
385- } `;
386- await gitUtils . commitAll ( finalCommitMessage ) ;
387- }
388-
389- await gitUtils . push ( versionBranch , { force : true } ) ;
378+ const finalCommitMessage = `${ commitMessage } ${
379+ ! ! preState ? ` (${ preState . tag } )` : ""
380+ } `;
381+
382+ await commitChangesFromRepo ( {
383+ octokit,
384+ owner : github . context . repo . owner ,
385+ repository : github . context . repo . repo ,
386+ branch : versionBranch ,
387+ // TODO: switch this to use direct string input when supported
388+ message : {
389+ headline : finalCommitMessage . split ( "\n" , 2 ) [ 0 ] . trim ( ) ,
390+ body : finalCommitMessage . split ( "\n" , 2 ) [ 1 ] ?. trim ( ) ,
391+ } ,
392+ base : {
393+ commit : github . context . sha ,
394+ } ,
395+ force : true ,
396+ } ) ;
390397
391398 let existingPullRequests = await existingPullRequestsPromise ;
392399 core . info ( JSON . stringify ( existingPullRequests . data , null , 2 ) ) ;
0 commit comments