Skip to content

Commit

Permalink
Add root and data/ as PR template paths (#220)
Browse files Browse the repository at this point in the history
## Overview
Add `root` and `data/` as default PR template paths, in addition to `.github/`. These are common paths mentioned in the [docs](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository#adding-a-pull-request-template) for creating PR templates.

## Test Plan
Created a test repro with `pull_request_template.md` in the root and verified that it's picked up when calling `av pr create`

```
❯ go run ./cmd/av -C /Users/andrew/dev/projects/test pr create
```
```
%% Creating pull request for branch 'foo'
%% Lines starting with '%%' will be ignored and an empty message aborts the
%% creation of the pull request.

%% Pull request title (single line)
Hello world

%% Pull request body (multiple lines)
A test PR template


%% This branch includes the following commits:
%%     8e34ff9    Hello world
```

fixes #219
  • Loading branch information
andrewwdye authored Jan 3, 2024
1 parent 49a7f5b commit 179cfcf
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions internal/actions/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,18 @@ var prBodyTemplate = template.Must(
)

func readDefaultPullRequestTemplate(repo *git.Repo) string {
for _, f := range []string{
"PULL_REQUEST_TEMPLATE.md",
"pull_request_template.md",
} {
tpl := filepath.Join(repo.Dir(), ".github", f)
data, err := os.ReadFile(tpl)
if err != nil {
continue
for _, dir := range []string{"", ".github", "data"} {
for _, f := range []string{
"PULL_REQUEST_TEMPLATE.md",
"pull_request_template.md",
} {
tpl := filepath.Join(repo.Dir(), dir, f)
data, err := os.ReadFile(tpl)
if err != nil {
continue
}
return string(data)
}
return string(data)
}
return ""
}
Expand Down

0 comments on commit 179cfcf

Please sign in to comment.