-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
import type { SimpleGit, SimpleGitOptions } from "simple-git"; | ||
import type { SimpleGit } from "simple-git"; | ||
import { simpleGit } from "simple-git"; | ||
|
||
export const createGitService = (git: SimpleGit) => { | ||
return git; | ||
import type { SubprocessService } from "../subprocess"; | ||
import { injectSubprocessService } from "../subprocess"; | ||
|
||
export const createGitService = ( | ||
git: SimpleGit, | ||
subprocess: SubprocessService, | ||
) => { | ||
return { | ||
raw: git, | ||
getMainBranch: async (cwd: string) => { | ||
await git.cwd(cwd); | ||
return ( | ||
await subprocess.exec( | ||
"git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'", | ||
{ | ||
cwd, | ||
}, | ||
) | ||
).trim(); | ||
}, | ||
}; | ||
}; | ||
|
||
export const injectGitService = (basePath: string) => { | ||
const options: Partial<SimpleGitOptions> = { | ||
baseDir: basePath, | ||
export const injectGitService = () => { | ||
const options = { | ||
binary: "git", | ||
maxConcurrentProcesses: 6, | ||
}; | ||
const git = simpleGit(options); | ||
|
||
return createGitService(git); | ||
const subprocess = injectSubprocessService(); | ||
|
||
return createGitService(git, subprocess); | ||
}; | ||
|
||
export type GitService = ReturnType<typeof createGitService>; |
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