-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f117ab5
commit c7dd50c
Showing
5 changed files
with
6 additions
and
142 deletions.
There are no files selected for viewing
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,59 +1,3 @@ | ||
const {Transform} = require("stream"); | ||
const changelog = require("standard-changelog"); | ||
|
||
var entry, blockedEntry, indent; | ||
var blocked = new Map(); | ||
|
||
function nextLine(t) { | ||
var offset = t.buffer.indexOf("\n"); | ||
if (offset >= 0) { | ||
var o = offset; | ||
if (t.buffer[o - 1] === 13) o--; // drop carriage-return before line-feed | ||
t.emit("line", t.buffer.toString("utf8", 0, o)); | ||
t.buffer = t.buffer.slice(offset + 1); | ||
process.nextTick(nextLine, t); | ||
} else | ||
t.callback(); | ||
} | ||
|
||
process.stdin.pipe( | ||
new Transform({ | ||
transform(chunk, encoding, callback) { | ||
this.buffer = this.buffer ? | ||
Buffer.concat([this.buffer, chunk], this.buffer.length + chunk.length) : | ||
Buffer.from(chunk); | ||
this.callback = callback; | ||
nextLine(this); | ||
}, | ||
flush(callback) { | ||
if (this.buffer && this.buffer.length > 0) // add line-feed to final line | ||
this._transform(Buffer.from("\n"), undefined, callback); | ||
else | ||
callback(); | ||
} | ||
}) | ||
.on("line", function(line) { | ||
if (/^commit\s+([0-9a-f]*)/.test(line)) { | ||
if (entry && entry.length > 2 && !blockedEntry) this.push(entry.join("")); | ||
blockedEntry = blocked.get(RegExp.$1); | ||
entry = undefined; | ||
} else if (/^Date:\s+(.*)$/.test(line)) | ||
entry = ["# " + RegExp.$1 + "\n"]; | ||
else if (entry && /^\s+\S/.test(line)) { | ||
if (entry.length === 1) | ||
entry.push(""); | ||
else if (entry.length === 2) { | ||
if (!/^(\s+)CHANGELOG(\s+([0-9a-f]*))?\s*$/.test(line)) | ||
entry = undefined; | ||
else { | ||
if (RegExp.$3) blocked.set(RegExp.$3, true); | ||
indent = RegExp.$1.length; | ||
entry.push(""); | ||
} | ||
} else | ||
entry.push(line.substr(indent) + "\n"); | ||
} | ||
}) | ||
.on("end", function() { | ||
if (entry && entry.length > 2 && !blockedEntry) process.stdout.write(entry.join("")); | ||
}) | ||
).pipe(process.stdout); | ||
changelog().pipe(process.stdout); |
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,13 +1,13 @@ | ||
remote=$(git remote show origin | grep -P -o "(?<=Push URL: ).*") | ||
folder=$(mktemp -d) | ||
git log | node lib/changelog >$folder/CHANGELOG.md | ||
node lib/changelog >$folder/CHANGELOG.md | ||
cd $folder | ||
git init -b main | ||
git add . | ||
git commit -m "changelog" | ||
git push --force $remote main:changelog | ||
|
||
# Alternative | ||
# git log | node lib/changelog >CHANGELOG.md | ||
# node lib/changelog >CHANGELOG.md | ||
# git diff-index --quiet HEAD || git commit -m "changelog" | ||
# git push |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.