Skip to content

Commit be4ece3

Browse files
committed
fix commit order on init
Signed-off-by: shmck <[email protected]>
1 parent 52efa78 commit be4ece3

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coderoad/cli",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "A CLI to build the configuration file for Coderoad Tutorials",
55
"keywords": [
66
"coderoad",

src/utils/commits.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type GetCommitOptions = {
1616

1717
export type CommitLogObject = { [position: string]: string[] };
1818

19-
20-
21-
export function parseCommits(logs: ListLogSummary<any>): { [hash: string]: string[]} {
19+
export function parseCommits(
20+
logs: ListLogSummary<any>
21+
): { [hash: string]: string[] } {
2222
// Filter relevant logs
2323
const commits: CommitLogObject = {};
2424
const positions: string[] = [];
@@ -30,31 +30,31 @@ export function parseCommits(logs: ListLogSummary<any>): { [hash: string]: strin
3030

3131
if (matches && matches.length) {
3232
// Use an object of commit arrays to collect all commits
33-
const { groups } = matches
34-
let position
33+
const { groups } = matches;
34+
let position;
3535
if (groups.init) {
36-
position = 'INIT'
36+
position = "INIT";
3737
} else if (groups.levelId && groups.stepId) {
38-
let stepType
38+
let stepType;
3939
// @deprecated Q
40-
if (!groups.stepType || ['Q', 'T'].includes(groups.stepType)) {
41-
stepType = 'T' // test
40+
if (!groups.stepType || ["Q", "T"].includes(groups.stepType)) {
41+
stepType = "T"; // test
4242
// @deprecated A
43-
} else if (!groups.stepType || ['A', 'S'].includes(groups.stepType)) {
44-
stepType = 'S' // solution
43+
} else if (!groups.stepType || ["A", "S"].includes(groups.stepType)) {
44+
stepType = "S"; // solution
4545
}
46-
position = `${groups.levelId}.${groups.stepId}:${stepType}`
46+
position = `${groups.levelId}.${groups.stepId}:${stepType}`;
4747
} else if (groups.levelId) {
48-
position = groups.levelId
48+
position = groups.levelId;
4949
} else {
50-
console.warn(`No matcher for commit "${commit.message}"`)
50+
console.warn(`No matcher for commit "${commit.message}"`);
5151
}
52-
commits[position] = [...(commits[position] || []), commit.hash]
52+
commits[position] = [...(commits[position] || []), commit.hash];
5353
positions.unshift(position);
5454
} else {
5555
const initMatches = commit.message.match(/^INIT/);
5656
if (initMatches && initMatches.length) {
57-
commits.INIT = [...(commits.INIT || []), commit.hash]
57+
commits.INIT = [commit.hash, ...(commits.INIT || [])];
5858
positions.unshift("INIT");
5959
}
6060
}

0 commit comments

Comments
 (0)