Skip to content

Commit

Permalink
Add simple changelog generator
Browse files Browse the repository at this point in the history
    $ oc adm release info --changelog=/tmp/git ...

Will generate an opinionated changelog in markdown from the payload.
It requires `oc adm release extract --git=DIR` to be invoked first,
and will scan for PR merge commits in those repos and expose them.
Issues that begin with `Bug [0-9]+: ` will be linked to bugzilla.

This will eventually also be able to print a list of bugs that can
be marked as part of the payload.
  • Loading branch information
smarterclayton committed Feb 13, 2019
1 parent b22f758 commit 9ea82ea
Show file tree
Hide file tree
Showing 4 changed files with 662 additions and 31 deletions.
4 changes: 4 additions & 0 deletions contrib/completions/bash/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions contrib/completions/zsh/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 17 additions & 9 deletions pkg/oc/cli/admin/release/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,10 @@ func (o *ExtractOptions) extractGit(dir string) error {
}
alreadyExtracted[repo] = commit

u, err := sourceLocationAsURL(repo)
basePath, err := sourceLocationAsRelativePath(dir, repo)
if err != nil {
return err
}
gitPath := u.Path
if strings.HasSuffix(gitPath, ".git") {
gitPath = strings.TrimSuffix(gitPath, ".git")
}
gitPath = path.Clean(gitPath)
basePath := filepath.Join(dir, u.Host, filepath.FromSlash(gitPath))

var git *git
fi, err := os.Stat(basePath)
Expand Down Expand Up @@ -341,14 +335,14 @@ func (g *git) basename() string {
}

func (g *git) CheckoutCommit(repo, commit string) error {
_, err := g.exec("rev-parse", commit)
_, err := g.exec("show-ref", commit)
if err == nil {
return nil
}

// try to fetch by URL
if _, err := g.exec("fetch", repo); err == nil {
if _, err := g.exec("rev-parse", commit); err == nil {
if _, err := g.exec("show-ref", commit); err == nil {
return nil
}
}
Expand All @@ -366,3 +360,17 @@ func sourceLocationAsURL(location string) (*url.URL, error) {
}
return url.Parse(location)
}

func sourceLocationAsRelativePath(dir, location string) (string, error) {
u, err := sourceLocationAsURL(location)
if err != nil {
return "", err
}
gitPath := u.Path
if strings.HasSuffix(gitPath, ".git") {
gitPath = strings.TrimSuffix(gitPath, ".git")
}
gitPath = path.Clean(gitPath)
basePath := filepath.Join(dir, u.Host, filepath.FromSlash(gitPath))
return basePath, nil
}
Loading

0 comments on commit 9ea82ea

Please sign in to comment.