pyronaur
pyronaur

Reputation: 3545

Node: git log between tags

With git you can get a pretty log of messages between two tags.

git log --pretty=oneline tagA...tagB

I've been using a Ruby Git Library that let me do the same thing with:

git = Git.open(".")
logs = git.log.between tagA, tagB

But I'm now trying to rewrite to something more compatible with Grunt and trying to find a decent way to do this with node. Right now the only way I can think of is making node interact with the terminal and get the output, but I don't think that would be a good way to do it.

Any suggestions ?

Upvotes: 3

Views: 593

Answers (1)

pyronaur
pyronaur

Reputation: 3545

Since I'm creating a tool just for my own use, I can afford to use synchronous shell, so this is what I ended up doing, because all the node git wrappers lack documentation a bit ( don't bash me, I've seen better docs... ) and are a bit overweight for my needs.

Using execSync

$shell = require("execSync")
result = $shell.exec "cd tmp/demo_git/ && git log --pretty=oneline #{from_tag}..#{to_tag}"

IMPORTANT: This is not a solution for server or an app! Doing this is okay only if you're writing a deployment app or something along those lines.

Upvotes: 1

Related Questions