Skip to content

Commit d561407

Browse files
JonghunYuclaude
andauthored
Fix 017 (#13)
* feat: added #15 * Close issue #16 * Close issue #15 * Close issue #17 * Fix: Use template when creating new issues Modified NewIssue function to read and use the template body from .issues/template.md when creating new issues. The template sections (Description, Requirements, Success Criteria) are now included in all newly created issues. Fixes #15 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bcdcbf3 commit d561407

5 files changed

Lines changed: 138 additions & 2 deletions

File tree

.issues/.counter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15
1+
18
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: "015"
3+
assignee: ""
4+
labels: []
5+
created: 2025-11-24T11:30:27.643813+09:00
6+
updated: 2025-11-24T12:14:28.9905+09:00
7+
---
8+
9+
# Make template work
10+
11+
## Description
12+
13+
The `gi create` command is not using the `.issues/template.md` file when creating new issues. New issues are created with minimal content instead of the structured template that includes Description, Requirements, and Success Criteria sections.
14+
15+
## Current Behavior
16+
17+
When running `gi create`, new issues are created with only:
18+
- YAML frontmatter (id, assignee, labels, created, updated)
19+
- A simple title heading
20+
- Empty content
21+
22+
## Expected Behavior
23+
24+
New issues should be created based on `.issues/template.md`, which includes:
25+
- YAML frontmatter (with appropriate fields populated)
26+
- Title heading
27+
- Description section with placeholder text
28+
- Requirements section with example bullet points
29+
- Success Criteria section with checkboxes
30+
31+
## Steps to Reproduce
32+
33+
1. Run `gi create` and enter an issue title
34+
2. Open the newly created issue file
35+
3. Observe that the file does not contain the template sections
36+
37+
## Impact
38+
39+
Users must manually add common sections (Description, Requirements, Success Criteria) to each new issue, reducing productivity and consistency across issues.
40+
41+
## Success Criteria
42+
43+
- [ ] `gi create` command reads `.issues/template.md` when creating new issues
44+
- [ ] Template sections (Description, Requirements, Success Criteria) appear in new issues
45+
- [ ] YAML frontmatter fields are properly populated (id, timestamps, etc.)
46+
- [ ] Title from user input replaces "Issue Title" placeholder in template
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "016"
3+
assignee: ""
4+
labels: []
5+
created: 2025-11-24T11:40:26.980336+09:00
6+
updated: 2025-11-24T11:40:41.888813+09:00
7+
---
8+
9+
# Test template functionality
10+
11+
## Description
12+
13+
Describe the issue here...
14+
15+
## Requirements
16+
17+
- Requirement 1
18+
- Requirement 2
19+
20+
## Success Criteria
21+
22+
- [ ] Criterion 1
23+
- [ ] Criterion 2
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
id: "017"
3+
assignee: user1
4+
labels:
5+
- feature
6+
created: 2025-11-24T12:14:42.020428+09:00
7+
updated: 2025-11-24T12:14:51.635438+09:00
8+
---
9+
10+
# Sample issue to show template
11+
12+
## Description
13+
14+
Describe the issue here...
15+
16+
## Requirements
17+
18+
- Requirement 1
19+
- Requirement 2
20+
21+
## Success Criteria
22+
23+
- [ ] Criterion 1
24+
- [ ] Criterion 2

pkg/storage.go

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,59 @@ func GetClosedPath() string {
326326
return filepath.Join(IssuesDir, ClosedDir)
327327
}
328328

329+
// LoadTemplateBody reads the template file and extracts the body content (after title heading)
330+
func LoadTemplateBody() string {
331+
templatePath := filepath.Join(IssuesDir, TemplateFile)
332+
333+
// Read template file
334+
data, err := os.ReadFile(templatePath)
335+
if err != nil {
336+
// If template doesn't exist, return empty body
337+
return ""
338+
}
339+
340+
// Parse the template to extract body
341+
content := string(data)
342+
parts := strings.SplitN(content, "---", 3)
343+
if len(parts) < 3 {
344+
// Invalid template format, return empty
345+
return ""
346+
}
347+
348+
// Get everything after frontmatter
349+
body := strings.TrimSpace(parts[2])
350+
351+
// Skip the title line (first # heading) and get everything after
352+
lines := strings.Split(body, "\n")
353+
for i, line := range lines {
354+
line = strings.TrimSpace(line)
355+
if strings.HasPrefix(line, "# ") {
356+
// Return everything after the title line
357+
if i+1 < len(lines) {
358+
return strings.TrimSpace(strings.Join(lines[i+1:], "\n"))
359+
}
360+
return ""
361+
}
362+
}
363+
364+
// If no title found, return the whole body
365+
return body
366+
}
367+
329368
// NewIssue creates a new Issue with default values
330369
func NewIssue(id int, title, assignee string, labels []string) *Issue {
331370
now := time.Now()
371+
372+
// Load template body
373+
templateBody := LoadTemplateBody()
374+
332375
return &Issue{
333376
ID: FormatID(id),
334377
Assignee: assignee,
335378
Labels: labels,
336379
Created: now,
337380
Updated: now,
338381
Title: title,
339-
Body: "",
382+
Body: templateBody,
340383
}
341384
}

0 commit comments

Comments
 (0)