Skip to content
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

Allow ; characters in merge commit messages #259

Merged
merged 2 commits into from
Mar 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,31 @@ export interface CommitListItem {
}

export function listCommits(from: string, to: string = ""): CommitListItem[] {
// Prints "<short-hash>;<ref-name>;<summary>;<date>"
// Prints "hash<short-hash> ref<ref-name> message<summary> date<date>"
// This format is used in `getCommitInfos` for easily analize the commit.
return execa
.sync("git", ["log", "--oneline", "--pretty=%h;%D;%s;%cd", "--date=short", `${from}..${to}`])
.sync("git", [
"log",
"--oneline",
"--pretty=hash<%h> ref<%D> message<%s> date<%cd>",
"--date=short",
`${from}..${to}`,
])
.stdout.split("\n")
.filter(Boolean)
.map((commit: string) => {
const parts = commit.split(";");
const sha = parts[0];
const refName = parts[1];
const summary = parts[2];
const date = parts[3];
const parts = commit.match(/hash<(.+)> ref<(.*)> message<(.*)> date<(.*)>/) || [];
tuchk4 marked this conversation as resolved.
Show resolved Hide resolved

if (!parts) {
return null;
tuchk4 marked this conversation as resolved.
Show resolved Hide resolved
}

const sha = parts[1];
const refName = parts[2];
const summary = parts[3];
const date = parts[4];

return { sha, refName, summary, date };
});
})
.filter(Boolean);
}