-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mcarvin8/fix/simple-git
fix: use simple-git for git commands
- Loading branch information
Showing
9 changed files
with
143 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
'use strict'; | ||
|
||
import * as promises from 'node:fs/promises'; | ||
import { execSync } from 'node:child_process'; | ||
import { SimpleGit } from 'simple-git'; | ||
|
||
export async function createTemporaryCommit(message: string, filePath: string, content: string): Promise<string> { | ||
export async function createTemporaryCommit( | ||
message: string, | ||
filePath: string, | ||
content: string, | ||
git: SimpleGit | ||
): Promise<string> { | ||
await promises.writeFile(filePath, content); | ||
|
||
// Stage the file | ||
execSync(`git add "${filePath}"`); | ||
await git.add(filePath); | ||
|
||
// Commit with the provided message | ||
execSync(`git commit -m "${message}"`); | ||
await git.commit(message); | ||
|
||
// Return the commit hash of the newly created commit | ||
const commitHash = execSync('git rev-parse HEAD', { encoding: 'utf-8' }).trim(); | ||
const commitHash = (await git.revparse('HEAD')).trim(); | ||
|
||
return commitHash; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.