Skip to content

Commit 73fc502

Browse files
committed
remove unix pipeline
1 parent 6382698 commit 73fc502

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

docs/scripts/generate-changelog.ts

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -118,57 +118,61 @@ async function execCommand(command: string): Promise<string> {
118118
}
119119

120120
/**
121-
* .changeset 폴더의 .md 파일들(README.md 제외)의 commit hash 가져오기
122-
* 각 changeset ID별로 해당하는 커밋 해시를 매핑하여 반환
121+
* changeset ID 목록에서 각 changeset의 commit hash 가져오기
122+
* releasePlan.changesets에서 ID를 받아 .changeset/<id>.md 경로로 커밋을 찾음
123123
*/
124-
async function getChangesetCommits(): Promise<Record<string, string>> {
125-
try {
126-
// .changeset 폴더의 .md 파일들 찾기 (README.md 제외)
127-
const files = await execCommand(
128-
"find .changeset -name '*.md' -not -name 'README.md' | head -10",
129-
);
130-
131-
if (!files) {
132-
console.log("📝 No changeset files found in .changeset folder");
124+
async function getChangesetCommits(
125+
changesetIds: string[],
126+
): Promise<Record<string, string>> {
127+
if (changesetIds.length === 0) {
128+
console.log("📝 No changeset IDs provided");
129+
return {};
130+
}
133131

134-
return {};
135-
}
132+
console.log(`📊 Processing ${changesetIds.length} changesets`);
136133

137-
const fileList = files.split("\n").filter((file) => file.trim());
138-
console.log(`📊 Found ${fileList.length} changeset files:`, fileList);
134+
const commitMap: Record<string, string> = {};
139135

140-
// 각 파일별로 main 브랜치에 머지된 commit 찾기
141-
const commitMap: Record<string, string> = {};
142-
for (const file of fileList) {
143-
// changeset ID 추출 (파일명에서 .md 제거)
144-
const changesetId = file.split("/").pop()?.replace(".md", "") || "";
136+
for (const changesetId of changesetIds) {
137+
const filePath = `.changeset/${changesetId}.md`;
145138

146-
// Version Packages 커밋을 제외하고 main 브랜치에 머지된 커밋 찾기
147-
const commit = await execCommand(
148-
`git log --oneline --first-parent main -- "${file}" | grep -v "Version Packages" | head -1 | cut -d' ' -f1`,
139+
try {
140+
// git log로 해당 파일을 추가한 커밋들 가져오기 (--format으로 해시와 메시지 분리)
141+
const logOutput = await execCommand(
142+
`git log --first-parent main --format="%H %s" -- "${filePath}"`,
149143
);
150144

151-
if (commit) {
152-
// 전체 커밋 해시 가져오기
153-
const fullCommit = await execCommand(`git rev-parse ${commit}`);
154-
if (fullCommit) {
155-
commitMap[changesetId] = fullCommit;
156-
console.log(` 📄 ${changesetId}${fullCommit.slice(0, 7)}`);
157-
}
145+
if (!logOutput) {
146+
continue;
158147
}
159-
}
160148

161-
if (Object.keys(commitMap).length === 0) {
162-
console.log("⚠️ No commits found for changeset files");
163-
return {};
149+
// 각 줄을 파싱하여 "Version Packages"가 아닌 첫 번째 커밋 찾기
150+
const lines = logOutput.split("\n").filter((line) => line.trim());
151+
for (const line of lines) {
152+
const spaceIndex = line.indexOf(" ");
153+
if (spaceIndex === -1) continue;
154+
155+
const commitHash = line.substring(0, spaceIndex);
156+
const message = line.substring(spaceIndex + 1);
157+
158+
if (!message.includes("Version Packages")) {
159+
commitMap[changesetId] = commitHash;
160+
console.log(` 📄 ${changesetId}${commitHash.slice(0, 7)}`);
161+
break;
162+
}
163+
}
164+
} catch {
165+
// 개별 changeset 실패는 무시하고 계속 진행
164166
}
167+
}
165168

166-
console.log(`✅ Found ${Object.keys(commitMap).length} changeset commits`);
167-
return commitMap;
168-
} catch (error) {
169-
console.log("⚠️ Error getting changeset commits:", error);
169+
if (Object.keys(commitMap).length === 0) {
170+
console.log("⚠️ No commits found for changeset files");
170171
return {};
171172
}
173+
174+
console.log(`✅ Found ${Object.keys(commitMap).length} changeset commits`);
175+
return commitMap;
172176
}
173177

174178
/**
@@ -222,7 +226,8 @@ async function organizeChangelogEntries(
222226

223227
if (releasePlan.changesets.length > 0) {
224228
// changeset 파일들의 commit hash 가져오기 (ID별로 매핑)
225-
const commitMap = await getChangesetCommits();
229+
const changesetIds = releasePlan.changesets.map((c) => c.id);
230+
const commitMap = await getChangesetCommits(changesetIds);
226231

227232
// 모든 changeset을 개별적으로 처리하며 각각의 커밋 링크 포함
228233
const changesetEntries = releasePlan.changesets.map((changeset) => {

0 commit comments

Comments
 (0)