Skip to content

Commit

Permalink
add context
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 3, 2021
1 parent a31242d commit 900f93c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/whatchanged-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func handler(w http.ResponseWriter, r *http.Request) {

url := fmt.Sprintf("https://github.com/%s/%s", username, repo)

if err = whatchanged.Generate(url, output, &option.Options{
if err = whatchanged.Generate(r.Context(), url, output, &option.Options{
Version: regexp.MustCompile(`\s+`).Split(version, -1),
Branch: branch,
Template: template,
Expand Down
3 changes: 2 additions & 1 deletion cmd/whatchanged/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"flag"
"fmt"
"os"
Expand Down Expand Up @@ -169,7 +170,7 @@ func run() error {
output = f
}

if err := whatchanged.Generate(project, output, &option.Options{
if err := whatchanged.Generate(context.Background(), project, output, &option.Options{
Version: ranges,
Branch: branch,
Preset: option.Preset(preset),
Expand Down
4 changes: 2 additions & 2 deletions whatchanged.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (

// generate changelog
// project: it could be a file path or a git URL
func Generate(project string, w io.Writer, options *option.Options) error {
func Generate(ctx context.Context, project string, w io.Writer, options *option.Options) error {
var (
err error
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func Generate(project string, w io.Writer, options *option.Options) error {
var g *client.GitClient

if gitHTTPURLReg.MatchString(project) || gitSSHURLReg.MatchString(project) {
repo, err := git.CloneContext(context.Background(), memory.NewStorage(), nil, &git.CloneOptions{
repo, err := git.CloneContext(ctx, memory.NewStorage(), nil, &git.CloneOptions{
URL: project,
Progress: os.Stderr,
SingleBranch: true,
Expand Down

0 comments on commit 900f93c

Please sign in to comment.