-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[engine] git log 파싱에 사용되는 separator 개선 #770
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
32d0475
chore(engine): constant 제거
yoouyeon 6702024
feat(engine): commit separator 설정
yoouyeon e6d29c7
fix(engine): sequence 오류 수정
yoouyeon b53e520
fix(engine): parents가 없는 경우의 오류 수정
yoouyeon 55e137a
chore(engine): 불필요한 출력 제거
yoouyeon d9c53fd
chore(vscode): 불필요한 import 제거
yoouyeon 4f97365
fix(engine): commit message, diffstat 파싱 로직 수정
yoouyeon 17901e1
test(engine): 변경된 포맷에 맞게 테스트케이스 변경
yoouyeon bed40d8
test(engine): 테스트케이스 형식 변경
yoouyeon 2ef4001
style(vscode): 불필요한 출력 제거
yoouyeon 1a9842f
style(vscode): 상수 선언 제거
yoouyeon 23cb127
style(engine): 상수명 변경
yoouyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,5 +1,4 @@ | ||
import { getCommitMessageType } from "./commit.util"; | ||
import { COMMIT_SEPARATOR, GIT_LOG_SEPARATOR } from "./constant"; | ||
import getCommitRaws from "./parser"; | ||
import type { CommitRaw, DifferenceStatistic } from "./types"; | ||
|
||
|
@@ -36,11 +35,15 @@ describe("commit message type", () => { | |
}); | ||
|
||
describe("getCommitRaws", () => { | ||
const fakeAuthorAndCommitter = `${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}[email protected]${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}[email protected]${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900`; | ||
const fakeCommitMessage = `${GIT_LOG_SEPARATOR}commit message${GIT_LOG_SEPARATOR}`; | ||
const fakeCommitMessageAndBody = `${GIT_LOG_SEPARATOR}commit message title\n\ncommit message body${GIT_LOG_SEPARATOR}`; | ||
const fakeCommitHash = `a${GIT_LOG_SEPARATOR}b`; | ||
const fakeCommitRef = `${GIT_LOG_SEPARATOR}HEAD`; | ||
const FRONT_NEW_LINE = "\n\n"; | ||
const INDENTATION = " "; | ||
|
||
const fakeAuthor = "John Park\[email protected]\nSun Sep 4 20:17:59 2022 +0900"; | ||
const fakeCommitter = `John Park 2\[email protected]\nSun Sep 5 20:17:59 2022 +0900`; | ||
const fakeCommitMessage = `commit message\n${INDENTATION}`; | ||
const fakeCommitMessageAndBody = `commit message title\n${INDENTATION}\n${INDENTATION}commit message body`; | ||
const fakeCommitHash = "a\nb"; | ||
const fakeCommitRef = "HEAD"; | ||
const fakeCommitFileChange = "10\t0\ta.ts\n1\t0\tREADME.md"; | ||
|
||
const commonExpectatedResult: CommitRaw = { | ||
|
@@ -73,23 +76,23 @@ describe("getCommitRaws", () => { | |
|
||
it.each([ | ||
[ | ||
`${COMMIT_SEPARATOR}${`a${GIT_LOG_SEPARATOR}`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${"a\n"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
id: "a", | ||
parents: [""], | ||
parents: [], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${`c${GIT_LOG_SEPARATOR}b`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${"c\nd"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
id: "c", | ||
parents: ["b"], | ||
parents: ["d"], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${`d${GIT_LOG_SEPARATOR}e f`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${"d\ne f"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
id: "d", | ||
|
@@ -103,47 +106,47 @@ describe("getCommitRaws", () => { | |
|
||
it.each([ | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: ["HEAD"], | ||
tags: [], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD -> main, origin/main, origin/HEAD"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: ["HEAD", "main", "origin/main", "origin/HEAD"], | ||
tags: [], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD, tag: v1.0.0`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD, tag: v1.0.0"}\n${fakeAuthor}\n${fakeCommitter}$\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: ["HEAD"], | ||
tags: ["v1.0.0"], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: ["HEAD", "main", "origin/main", "origin/HEAD"], | ||
tags: ["v2.0.0"], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD, tag: v2.0.0, tag: v1.4`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD, tag: v2.0.0, tag: v1.4"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: ["HEAD"], | ||
tags: ["v2.0.0", "v1.4"], | ||
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${GIT_LOG_SEPARATOR}${fakeAuthorAndCommitter}${fakeCommitMessage}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${""}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, | ||
{ | ||
...commonExpectatedResult, | ||
branches: [], | ||
|
@@ -157,7 +160,7 @@ describe("getCommitRaws", () => { | |
|
||
it.each([ | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"10\t0\ta.ts\n1\t0\tREADME.md"}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"10\t0\ta.ts\n1\t0\tREADME.md"}`, | ||
{ | ||
...commonExpectatedResult, | ||
differenceStatistic: { | ||
|
@@ -171,7 +174,7 @@ describe("getCommitRaws", () => { | |
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"3\t3\ta.ts"}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"3\t3\ta.ts"}`, | ||
{ | ||
...commonExpectatedResult, | ||
differenceStatistic: { | ||
|
@@ -182,7 +185,7 @@ describe("getCommitRaws", () => { | |
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"4\t0\ta.ts"}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"4\t0\ta.ts"}`, | ||
{ | ||
...commonExpectatedResult, | ||
differenceStatistic: { | ||
|
@@ -193,7 +196,7 @@ describe("getCommitRaws", () => { | |
}, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts"}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts"}`, | ||
{ | ||
...commonExpectatedResult, | ||
differenceStatistic: { | ||
|
@@ -213,7 +216,7 @@ describe("getCommitRaws", () => { | |
}); | ||
|
||
it(`should parse gitlog to commitRaw(multiple commits)`, () => { | ||
const mockLog = `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${fakeCommitFileChange}${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`; | ||
const mockLog = `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${fakeCommitFileChange}\n\n\n\n${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`; | ||
const result = getCommitRaws(mockLog); | ||
const expectedResult = [ | ||
{ ...commonExpectatedResult, differenceStatistic: expectedFileChange }, | ||
|
@@ -225,23 +228,23 @@ describe("getCommitRaws", () => { | |
|
||
it.each([ | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title${GIT_LOG_SEPARATOR}`}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}`, | ||
{ ...commonExpectatedResult, message: "commit message title" }, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\ncommit message${GIT_LOG_SEPARATOR}`}`, | ||
{ ...commonExpectatedResult, message: "commit message title\ncommit message" }, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}${"commit message body"}`, | ||
{ ...commonExpectatedResult, message: "commit message title\ncommit message body" }, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\n\ncommit message body${GIT_LOG_SEPARATOR}`}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}\n${INDENTATION}${"commit message body"}`, | ||
{ ...commonExpectatedResult, message: "commit message title\n\ncommit message body" }, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\n\n\ncommit message body${GIT_LOG_SEPARATOR}`}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}\n${INDENTATION}\n${INDENTATION}${"commit message body"}`, | ||
{ ...commonExpectatedResult, message: "commit message title\n\n\ncommit message body" }, | ||
], | ||
[ | ||
`${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}${GIT_LOG_SEPARATOR}`}`, | ||
`${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n\n${INDENTATION}`, | ||
{ ...commonExpectatedResult, message: "" }, | ||
], | ||
])("should parse gitlog to commitRaw(commit message)", (mockLog, expectedResult) => { | ||
|
@@ -250,7 +253,7 @@ describe("getCommitRaws", () => { | |
}); | ||
|
||
it(`should parse gitlog to commitRaw(commit message body and file change)`, () => { | ||
const mockLog = `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessageAndBody}\n${fakeCommitFileChange}`; | ||
const mockLog = `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessageAndBody}\n${fakeCommitFileChange}`; | ||
const result = getCommitRaws(mockLog); | ||
const expectedResult = { | ||
...commonExpectatedResult, | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
드디어 사라졌군요!!! 🎆🎆🎆