1004
by eloaders
Fixes #8 Reconstruction of code |
1 |
#!/usr/bin/awk -f
|
2 |
BEGIN { |
|
3 |
REPO_URL = getRepoURL() |
|
4 |
# Prefixes that determine whether a commit will be printed
|
|
5 |
#CHANGELOG_REGEX = "^(changelog|Update|fix|add|docs|chore|feat|feature|refactor|update||): "
|
|
6 |
FS="|" |
|
7 |
# %D: tags
|
|
8 |
# %s: commit message
|
|
9 |
# %H: long hash
|
|
10 |
# %h: short hash
|
|
11 |
while ("git log --pretty='%D|%s|%H|%h'" | getline) { |
|
12 |
IS_GIT_TAG = length($1) && match($1, /tag:/) |
|
13 |
if (IS_GIT_TAG) { |
|
14 |
printTag($1) |
|
15 |
} else { |
|
16 |
printCommit($2, $3, $4) |
|
17 |
}
|
|
18 |
||
19 |
}
|
|
20 |
}
|
|
21 |
function printTag(input) { |
|
22 |
# Cut out text up to tag
|
|
23 |
sub(/.*tag: /, "", input) |
|
24 |
# Cut out text after tag
|
|
25 |
sub(/,.*/, "", input) |
|
26 |
if (TYPE == "plain") |
|
27 |
printf("\n%s\n", input) |
|
28 |
else
|
|
29 |
printf("\n## %s\n", input) |
|
30 |
}
|
|
31 |
function printCommit(input, longHash, shortHash) { |
|
1007
by eloaders
Fix: Repo URL |
32 |
#if ( match(input, CHANGELOG_REGEX) ) {
|
33 |
#sub(CHANGELOG_REGEX, "", input)
|
|
1004
by eloaders
Fixes #8 Reconstruction of code |
34 |
if (TYPE == "plain") |
35 |
printf("\t- %s\n", input, makeCommitLink(REPO_URL, shortHash, longHash) ) |
|
36 |
else
|
|
37 |
printf("- %s (%s)\n", input, makeCommitLink(REPO_URL, shortHash, longHash) ) |
|
1007
by eloaders
Fix: Repo URL |
38 |
#}
|
1004
by eloaders
Fixes #8 Reconstruction of code |
39 |
}
|
40 |
function makeCommitLink(repoUrl, shortHash, longHash) { |
|
1007
by eloaders
Fix: Repo URL |
41 |
return ("[" shortHash "](" repoUrl "/commit/" longHash ")") |
1004
by eloaders
Fixes #8 Reconstruction of code |
42 |
}
|
43 |
||
44 |
# Get Git repo URL
|
|
45 |
function getRepoURL() { |
|
46 |
"git config --get remote.upstream.url || git config --get remote.origin.url || git config --get remote.dev.url" | getline REPO_URL |
|
47 |
sub(/:/, "/", REPO_URL) |
|
48 |
sub(/git@/, "https://", REPO_URL) |
|
49 |
sub(/\.git/, "", REPO_URL) |
|
50 |
return REPO_URL |
|
51 |
}
|