Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec6afa7

Browse files
authored
Instruct LLM to use pull request template when creating PRs (#1442)
1 parent548c27c commitec6afa7

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

‎pkg/github/instructions.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func GenerateInstructions(enabledToolsets []string) string {
2222

2323
// Individual toolset instructions
2424
for_,toolset:=rangeenabledToolsets {
25-
ifinst:=getToolsetInstructions(toolset);inst!="" {
25+
ifinst:=getToolsetInstructions(toolset,enabledToolsets);inst!="" {
2626
instructions=append(instructions,inst)
2727
}
2828
}
@@ -48,12 +48,18 @@ Tool usage guidance:
4848
}
4949

5050
// getToolsetInstructions returns specific instructions for individual toolsets
51-
funcgetToolsetInstructions(toolsetstring)string {
51+
funcgetToolsetInstructions(toolsetstring,enabledToolsets []string)string {
5252
switchtoolset {
5353
case"pull_requests":
54-
return`## Pull Requests
54+
pullRequestInstructions:=`## Pull Requests
5555
5656
PR review workflow: Always use 'pull_request_review_write' with method 'create' to create a pending review, then 'add_comment_to_pending_review' to add comments, and finally 'pull_request_review_write' with method 'submit_pending' to submit the review for complex reviews with line-specific comments.`
57+
ifslices.Contains(enabledToolsets,"repos") {
58+
pullRequestInstructions+=`
59+
60+
Before creating a pull request, search for pull request templates in the repository. Template files are called pull_request_template.md or they're located in '.github/PULL_REQUEST_TEMPLATE' directory. Use the template content to structure the PR description and then call create_pull_request tool.`
61+
}
62+
returnpullRequestInstructions
5763
case"issues":
5864
return`## Issues
5965

‎pkg/github/instructions_test.go‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"os"
5+
"strings"
56
"testing"
67
)
78

@@ -128,12 +129,23 @@ func TestGenerateInstructionsWithDisableFlag(t *testing.T) {
128129

129130
funcTestGetToolsetInstructions(t*testing.T) {
130131
tests:= []struct {
131-
toolsetstring
132-
expectedEmptybool
132+
toolsetstring
133+
expectedEmptybool
134+
enabledToolsets []string
135+
expectedToContainstring
136+
notExpectedToContainstring
133137
}{
134138
{
135-
toolset:"pull_requests",
136-
expectedEmpty:false,
139+
toolset:"pull_requests",
140+
expectedEmpty:false,
141+
enabledToolsets: []string{"pull_requests","repos"},
142+
expectedToContain:"pull_request_template.md",
143+
},
144+
{
145+
toolset:"pull_requests",
146+
expectedEmpty:false,
147+
enabledToolsets: []string{"pull_requests"},
148+
notExpectedToContain:"pull_request_template.md",
137149
},
138150
{
139151
toolset:"issues",
@@ -151,7 +163,7 @@ func TestGetToolsetInstructions(t *testing.T) {
151163

152164
for_,tt:=rangetests {
153165
t.Run(tt.toolset,func(t*testing.T) {
154-
result:=getToolsetInstructions(tt.toolset)
166+
result:=getToolsetInstructions(tt.toolset,tt.enabledToolsets)
155167
iftt.expectedEmpty {
156168
ifresult!="" {
157169
t.Errorf("Expected empty result for toolset '%s', but got: %s",tt.toolset,result)
@@ -161,6 +173,14 @@ func TestGetToolsetInstructions(t *testing.T) {
161173
t.Errorf("Expected non-empty result for toolset '%s', but got empty",tt.toolset)
162174
}
163175
}
176+
177+
iftt.expectedToContain!=""&&!strings.Contains(result,tt.expectedToContain) {
178+
t.Errorf("Expected result to contain '%s' for toolset '%s', but it did not. Result: %s",tt.expectedToContain,tt.toolset,result)
179+
}
180+
181+
iftt.notExpectedToContain!=""&&strings.Contains(result,tt.notExpectedToContain) {
182+
t.Errorf("Did not expect result to contain '%s' for toolset '%s', but it did. Result: %s",tt.notExpectedToContain,tt.toolset,result)
183+
}
164184
})
165185
}
166186
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp