Created
August 13, 2015 21:55
-
-
Save maddyblue/6172104dca644e5b8cf0 to your computer and use it in GitHub Desktop.
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
/* | |
Command er-release prints the PRs merged since the last release | |
These should be added to CHANGELOG.md with an appropriate version. | |
*/ | |
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"os/exec" | |
"strings" | |
) | |
var ( | |
from = flag.String("from", "", "git tree-ish of the previous release; defaults to the last change of CHANGELOG.md") | |
to = flag.String("to", "HEAD", "git tree-ish of the current release") | |
) | |
func main() { | |
flag.Parse() | |
if *from == "" { | |
if err := setLastChangelog(); err != nil { | |
log.Fatal(err) | |
} | |
} | |
fmt.Println(*from, *to) | |
out, err := git("log", *from+".."+*to) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(string(out)) | |
} | |
func setLastChangelog() error { | |
out, err := git("log", "--format=format:%H", "-1", "CHANGELOG.md") | |
if err != nil { | |
return err | |
} | |
*from = strings.TrimSpace(string(out)) | |
return nil | |
} | |
func git(args ...string) ([]byte, error) { | |
return exec.Command("git", args...).Output() | |
} | |
func split(s string) []string) { | |
re := regexp.MustCompile("^commit ") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment