-
Notifications
You must be signed in to change notification settings - Fork 83
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 #713 from BeA-Pro/main
[engine] Worker를 활용한 깃 로그 받아오기
- Loading branch information
Showing
6 changed files
with
129 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as cp from 'child_process'; | ||
import { parentPort, workerData } from 'worker_threads'; | ||
|
||
import { resolveSpawnOutput } from './git.util' | ||
|
||
const { gitPath, currentWorkspacePath, skipCount, limitCount } = workerData; | ||
|
||
async function getPartialGitLog() { | ||
const args = [ | ||
'--no-pager', | ||
'log', | ||
'--all', | ||
'--parents', | ||
'--numstat', | ||
'--date-order', | ||
'--pretty=fuller', | ||
'--decorate', | ||
'-c', | ||
`--skip=${skipCount}`, | ||
`-n ${limitCount}`, | ||
]; | ||
|
||
resolveSpawnOutput( | ||
cp.spawn(gitPath, args, { | ||
cwd: currentWorkspacePath, | ||
env: Object.assign({}, process.env), | ||
}) | ||
).then(([status, stdout, stderr]) => { | ||
const { code, error } = status; | ||
|
||
if (code === 0 && !error && parentPort !== null) { | ||
parentPort.postMessage(stdout.toString()); | ||
} else { | ||
if (parentPort !== null) parentPort.postMessage(stderr); | ||
} | ||
}).catch(error => { | ||
console.error('Spawn Error:', error); | ||
}); | ||
} | ||
|
||
getPartialGitLog(); |
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