Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 2, 2021
1 parent 415fcc3 commit 7390c46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/whatchanged-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func handler(w http.ResponseWriter, r *http.Request) {

username := query.Get("username")
repo := query.Get("repo")
branch := query.Get("branch")
version := query.Get("version")
template := query.Get("template")
preset := query.Get("preset")
Expand All @@ -57,6 +58,7 @@ func handler(w http.ResponseWriter, r *http.Request) {

if err = whatchanged.Generate(url, output, &option.Options{
Version: regexp.MustCompile(`\s+`).Split(version, -1),
Branch: branch,
Template: template,
Preset: option.Preset(preset),
}); err != nil {
Expand Down
1 change: 1 addition & 0 deletions option/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (

type Options struct {
Version []string
Branch string
Format Format
SkipFormat bool
Preset Preset // Priority: 1 The higher the level, the more priority
Expand Down
14 changes: 10 additions & 4 deletions whatchanged.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/axetroy/whatchanged/internal/client"
"github.com/axetroy/whatchanged/option"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -46,6 +47,10 @@ func Generate(project string, w io.Writer, options *option.Options) error {
}
}

if options.Branch == "" {
options.Branch = "master"
}

if options.TemplateFile != "" {
cwd, err := os.Getwd()

Expand All @@ -62,10 +67,11 @@ func Generate(project string, w io.Writer, options *option.Options) error {

if gitHTTPURLReg.MatchString(project) || gitSSHURLReg.MatchString(project) {
repo, err := git.CloneContext(context.Background(), memory.NewStorage(), nil, &git.CloneOptions{
URL: project,
Progress: os.Stderr,
SingleBranch: true,
Tags: git.AllTags,
URL: project,
Progress: os.Stderr,
SingleBranch: true,
ReferenceName: plumbing.NewBranchReferenceName(options.Branch),
Tags: git.AllTags,
})

if err != nil {
Expand Down

0 comments on commit 7390c46

Please sign in to comment.