Skip to content

Commit

Permalink
Exclude pull request author (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon authored Sep 27, 2022
1 parent 8b89374 commit dcc1310
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Install the [Codenotify](https://github.com/apps/codenotify) GitHub App on your
- [Go](https://golang.org/doc/install) (v1.19 or higher)
- [Task](https://github.com/go-task/task) (v3)
- [ngrok](https://ngrok.com/)
- [Codenotify](https://github.com/sourcegraph/codenotify) (v0.6.3 or higher)
- [Codenotify](https://github.com/sourcegraph/codenotify) (v0.6.4 or higher)

#### macOS

Expand All @@ -36,7 +36,7 @@ Install the [Codenotify](https://github.com/apps/codenotify) GitHub App on your

```bash
brew install git go go-task/tap/go-task ngrok
go install https://github.com/sourcegraph/codenotify@latest
go install https://github.com/sourcegraph/codenotify@v0.6.4

# In the root directory of the repository
ln -s $(go env GOPATH)/bin/codenotify $(pwd)/.bin/codenotify
Expand Down
3 changes: 2 additions & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ func checkout(ctx context.Context, w io.Writer, repoPath, remoteURL, headCommit
return nil
}

func codenotify(ctx context.Context, w io.Writer, binPath, repoPath, baseRef, headRef string) (string, error) {
func codenotify(ctx context.Context, w io.Writer, binPath, repoPath, baseRef, headRef, author string) (string, error) {
output, err := run(
ctx,
w,
binPath,
"--cwd", repoPath,
"--baseRef", baseRef,
"--headRef", headRef,
"--author", "@"+author,
"--format=markdown",
"--filename=CODENOTIFY",
"--subscriber-threshold=10",
Expand Down
12 changes: 10 additions & 2 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func logPathByRunID(rootDir, runID string) string {

func checkoutAndRun(ctx context.Context, config *conf.Config, payload *github.PullRequestEvent, token string) (output string, runID string, err error) {
tmpPath := fmt.Sprintf("tmp/repos/%s-%d", *payload.PullRequest.NodeID, time.Now().Unix())
err = os.MkdirAll(path.Dir(tmpPath), os.ModeDir)
err = os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
if err != nil {
return "", "", errors.Wrap(err, "create temp directory")
}
Expand Down Expand Up @@ -147,7 +147,15 @@ func checkoutAndRun(ctx context.Context, config *conf.Config, payload *github.Pu
return "", id.String(), errors.Wrap(err, "checkout pull request")
}

output, err = codenotify(ctx, &buf, config.Codenotify.BinPath, tmpPath, *payload.PullRequest.Base.SHA, *payload.PullRequest.Head.SHA)
output, err = codenotify(
ctx,
&buf,
config.Codenotify.BinPath,
tmpPath,
*payload.PullRequest.Base.SHA,
*payload.PullRequest.Head.SHA,
*payload.PullRequest.User.Login,
)
if err != nil {
return "", id.String(), errors.Wrap(err, "run Codenotify")
}
Expand Down

0 comments on commit dcc1310

Please sign in to comment.