commenter 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +7 -102
- data/README.adoc +71 -3
- data/data/github_config_sample.yaml +8 -0
- data/data/github_issue_body_template.liquid +1 -1
- data/data/github_issue_title_template.liquid +1 -1
- data/lib/commenter/cli.rb +4 -1
- data/lib/commenter/comment.rb +10 -1
- data/lib/commenter/github_integration.rb +67 -21
- data/lib/commenter/version.rb +1 -1
- data/spec/commenter/comment_spec.rb +2 -2
- data/spec/commenter/github_integration_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31fa0d4ee056c833d9f2b329d994e5d6151e3430426e6d4f02dfca4c670d0c18
|
|
4
|
+
data.tar.gz: b459baef384850cfa84cfb22c48212771ee57fa0e11cbd803c1db33dfb44aae2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 989ff9a26a63210438385658edaee8a0d94a35c9d80916dfefe89575ce739f9efc75bdcc372d737a955de236fdefdeaaca0be65146363dea5833ac280cc97cdb
|
|
7
|
+
data.tar.gz: 5cdcb2b0ca204b6e419d009f45eeb6dfd4867c7eb51196a04ad2499c7c64e5cb5288b85522f031a7a823e9242c3e8edec771d7c2d1bb8f5f9b079df7e86cc54b
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,80 +1,21 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-03-16 10:59:51 UTC using RuboCop version 1.85.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
9
|
# Offense count: 1
|
|
10
|
-
# Configuration parameters: Severity, Include.
|
|
11
|
-
# Include: **/*.gemspec
|
|
12
10
|
Gemspec/RequiredRubyVersion:
|
|
13
11
|
Exclude:
|
|
14
12
|
- 'commenter.gemspec'
|
|
15
13
|
|
|
16
|
-
# Offense count: 1
|
|
17
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
18
|
-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
|
19
|
-
# SupportedStylesAlignWith: start_of_line, begin
|
|
20
|
-
Layout/BeginEndAlignment:
|
|
21
|
-
Exclude:
|
|
22
|
-
- 'lib/commenter/parser.rb'
|
|
23
|
-
|
|
24
|
-
# Offense count: 1
|
|
25
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
26
|
-
# Configuration parameters: EnforcedStyle.
|
|
27
|
-
# SupportedStyles: empty_lines, no_empty_lines
|
|
28
|
-
Layout/EmptyLinesAroundBlockBody:
|
|
29
|
-
Exclude:
|
|
30
|
-
- 'spec/commenter_spec.rb'
|
|
31
|
-
|
|
32
|
-
# Offense count: 2
|
|
33
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
34
|
-
# Configuration parameters: Width, AllowedPatterns.
|
|
35
|
-
Layout/IndentationWidth:
|
|
36
|
-
Exclude:
|
|
37
|
-
- 'lib/commenter/parser.rb'
|
|
38
|
-
|
|
39
|
-
# Offense count: 1
|
|
40
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
41
|
-
Layout/RescueEnsureAlignment:
|
|
42
|
-
Exclude:
|
|
43
|
-
- 'lib/commenter/parser.rb'
|
|
44
|
-
|
|
45
14
|
# Offense count: 1
|
|
46
15
|
Lint/NonLocalExitFromIterator:
|
|
47
16
|
Exclude:
|
|
48
17
|
- 'lib/commenter/filler.rb'
|
|
49
18
|
|
|
50
|
-
# Offense count: 4
|
|
51
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
52
|
-
Lint/SafeNavigationWithEmpty:
|
|
53
|
-
Exclude:
|
|
54
|
-
- 'lib/commenter/parser.rb'
|
|
55
|
-
|
|
56
|
-
# Offense count: 1
|
|
57
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
58
|
-
# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
|
59
|
-
Lint/UnusedBlockArgument:
|
|
60
|
-
Exclude:
|
|
61
|
-
- 'lib/commenter/filler.rb'
|
|
62
|
-
|
|
63
|
-
# Offense count: 4
|
|
64
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
65
|
-
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
66
|
-
# NotImplementedExceptions: NotImplementedError
|
|
67
|
-
Lint/UnusedMethodArgument:
|
|
68
|
-
Exclude:
|
|
69
|
-
- 'lib/commenter/github_integration.rb'
|
|
70
|
-
|
|
71
|
-
# Offense count: 1
|
|
72
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
73
|
-
# Configuration parameters: AutoCorrect.
|
|
74
|
-
Lint/UselessAssignment:
|
|
75
|
-
Exclude:
|
|
76
|
-
- 'lib/commenter/parser.rb'
|
|
77
|
-
|
|
78
19
|
# Offense count: 15
|
|
79
20
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
80
21
|
Metrics/AbcSize:
|
|
@@ -89,9 +30,9 @@ Metrics/BlockLength:
|
|
|
89
30
|
# Offense count: 5
|
|
90
31
|
# Configuration parameters: CountComments, CountAsOne.
|
|
91
32
|
Metrics/ClassLength:
|
|
92
|
-
Max:
|
|
33
|
+
Max: 231
|
|
93
34
|
|
|
94
|
-
# Offense count:
|
|
35
|
+
# Offense count: 8
|
|
95
36
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
96
37
|
Metrics/CyclomaticComplexity:
|
|
97
38
|
Max: 22
|
|
@@ -101,7 +42,7 @@ Metrics/CyclomaticComplexity:
|
|
|
101
42
|
Metrics/MethodLength:
|
|
102
43
|
Max: 53
|
|
103
44
|
|
|
104
|
-
# Offense count:
|
|
45
|
+
# Offense count: 8
|
|
105
46
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
106
47
|
Metrics/PerceivedComplexity:
|
|
107
48
|
Max: 22
|
|
@@ -112,7 +53,7 @@ Metrics/PerceivedComplexity:
|
|
|
112
53
|
# ForbiddenPrefixes: is_, has_, have_, does_
|
|
113
54
|
# AllowedMethods: is_a?
|
|
114
55
|
# MethodDefinitionMacros: define_method, define_singleton_method
|
|
115
|
-
Naming/
|
|
56
|
+
Naming/PredicatePrefix:
|
|
116
57
|
Exclude:
|
|
117
58
|
- 'spec/**/*'
|
|
118
59
|
- 'lib/commenter/comment.rb'
|
|
@@ -130,45 +71,9 @@ Style/Documentation:
|
|
|
130
71
|
- 'lib/commenter/github_integration.rb'
|
|
131
72
|
- 'lib/commenter/parser.rb'
|
|
132
73
|
|
|
133
|
-
# Offense count: 1
|
|
134
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
135
|
-
# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments.
|
|
136
|
-
# SupportedStyles: empty, nil, both
|
|
137
|
-
Style/EmptyElse:
|
|
138
|
-
Exclude:
|
|
139
|
-
- 'lib/commenter/filler.rb'
|
|
140
|
-
|
|
141
74
|
# Offense count: 3
|
|
142
75
|
# This cop supports safe autocorrection (--autocorrect).
|
|
143
|
-
|
|
144
|
-
Exclude:
|
|
145
|
-
- 'lib/commenter/cli.rb'
|
|
146
|
-
- 'lib/commenter/github_integration.rb'
|
|
147
|
-
- 'lib/commenter/parser.rb'
|
|
148
|
-
|
|
149
|
-
# Offense count: 1
|
|
150
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
151
|
-
Style/MultilineIfModifier:
|
|
152
|
-
Exclude:
|
|
153
|
-
- 'lib/commenter/parser.rb'
|
|
154
|
-
|
|
155
|
-
# Offense count: 2
|
|
156
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
157
|
-
Style/RescueModifier:
|
|
158
|
-
Exclude:
|
|
159
|
-
- 'lib/commenter/parser.rb'
|
|
160
|
-
|
|
161
|
-
# Offense count: 2
|
|
162
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
163
|
-
# Configuration parameters: EnforcedStyle.
|
|
164
|
-
# SupportedStyles: implicit, explicit
|
|
165
|
-
Style/RescueStandardError:
|
|
166
|
-
Exclude:
|
|
167
|
-
- 'lib/commenter/parser.rb'
|
|
168
|
-
|
|
169
|
-
# Offense count: 2
|
|
170
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
171
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
76
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
172
77
|
# URISchemes: http, https
|
|
173
78
|
Layout/LineLength:
|
|
174
|
-
Max:
|
|
79
|
+
Max: 138
|
data/README.adoc
CHANGED
|
@@ -227,6 +227,7 @@ The title template (`data/github_issue_title_template.liquid`) supports these va
|
|
|
227
227
|
* `body` - Member body abbreviation
|
|
228
228
|
* `type` - Comment type code
|
|
229
229
|
* `clause`, `element`, `line_number` - Location information
|
|
230
|
+
* `unique_id` - Rendered unique identifier (see <<_duplicate_detection>>)
|
|
230
231
|
|
|
231
232
|
===== Body template variables
|
|
232
233
|
|
|
@@ -256,6 +257,7 @@ github:
|
|
|
256
257
|
templates:
|
|
257
258
|
title: "custom_title.liquid"
|
|
258
259
|
body: "custom_body.liquid"
|
|
260
|
+
unique_id: "[{{ stage | upcase }}] {{ comment_id }}" # Optional: customize unique ID
|
|
259
261
|
----
|
|
260
262
|
====
|
|
261
263
|
|
|
@@ -301,9 +303,75 @@ $ commenter github comments.yaml --config github_config.yaml
|
|
|
301
303
|
|
|
302
304
|
==== Duplicate detection
|
|
303
305
|
|
|
304
|
-
The gem automatically checks for existing issues to avoid duplicates
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
The gem automatically checks for existing issues to avoid duplicates. The duplicate
|
|
307
|
+
detection uses a **configurable unique identifier** that is:
|
|
308
|
+
|
|
309
|
+
. Rendered from a Liquid template
|
|
310
|
+
. Embedded in the issue title for human identification
|
|
311
|
+
. Used as the search pattern to find existing issues
|
|
312
|
+
|
|
313
|
+
This ensures that the search pattern always matches what appears in the title,
|
|
314
|
+
preventing synchronization issues.
|
|
315
|
+
|
|
316
|
+
===== Unique ID template
|
|
317
|
+
|
|
318
|
+
The unique identifier is defined by the `unique_id` template in your configuration:
|
|
319
|
+
|
|
320
|
+
[source,yaml]
|
|
321
|
+
----
|
|
322
|
+
github:
|
|
323
|
+
templates:
|
|
324
|
+
# Default: "[STAGE] COMMENT_ID"
|
|
325
|
+
unique_id: "[{{ stage | upcase }}] {{ comment_id }}"
|
|
326
|
+
----
|
|
327
|
+
|
|
328
|
+
The default renders to: `[DIS] GB-001`
|
|
329
|
+
|
|
330
|
+
===== Why stage-aware unique IDs?
|
|
331
|
+
|
|
332
|
+
ISO standards go through multiple ballot stages (WD, CD, DIS, FDIS). The same
|
|
333
|
+
comment ID (e.g., `GB-001`) appears at each stage, but represents **different
|
|
334
|
+
comments**:
|
|
335
|
+
|
|
336
|
+
| Stage | Comment ID | Unique ID | Same Issue? |
|
|
337
|
+
|-------|------------|-----------|-------------|
|
|
338
|
+
| CD | GB-001 | `[CD] GB-001` | No |
|
|
339
|
+
| DIS | GB-001 | `[DIS] GB-001` | No |
|
|
340
|
+
|
|
341
|
+
Without stage-aware unique IDs, CD `GB-001` and DIS `GB-001` would be treated as
|
|
342
|
+
duplicates, causing the DIS comment to be skipped.
|
|
343
|
+
|
|
344
|
+
===== Custom unique ID patterns
|
|
345
|
+
|
|
346
|
+
You can customize the unique ID pattern to match your title template format:
|
|
347
|
+
|
|
348
|
+
[source,yaml]
|
|
349
|
+
----
|
|
350
|
+
github:
|
|
351
|
+
templates:
|
|
352
|
+
# Different order
|
|
353
|
+
unique_id: "{{ comment_id }} [{{ stage | upcase }}]"
|
|
354
|
+
|
|
355
|
+
# With document prefix
|
|
356
|
+
unique_id: "{{ document }} - {{ comment_id }}"
|
|
357
|
+
|
|
358
|
+
# With body prefix (for multi-body projects)
|
|
359
|
+
unique_id: "{{ body }}/{{ comment_id }}"
|
|
360
|
+
|
|
361
|
+
# Single stage project (no stage needed)
|
|
362
|
+
unique_id: "{{ comment_id }}"
|
|
363
|
+
----
|
|
364
|
+
|
|
365
|
+
===== Using unique_id in templates
|
|
366
|
+
|
|
367
|
+
The `unique_id` is available as a variable in title and body templates:
|
|
368
|
+
|
|
369
|
+
[source,liquid]
|
|
370
|
+
----
|
|
371
|
+
{{ unique_id }}: {{ brief_summary }} {% if document %}({{ document }}){% endif %}
|
|
372
|
+
----
|
|
373
|
+
|
|
374
|
+
This renders to: `[DIS] GB-001: Clause 5.1 summary (ISO/DIS 2533)`
|
|
307
375
|
|
|
308
376
|
==== Retrieving observations from GitHub issues
|
|
309
377
|
|
|
@@ -61,9 +61,17 @@ github:
|
|
|
61
61
|
|
|
62
62
|
# Custom template paths (optional)
|
|
63
63
|
templates:
|
|
64
|
+
# Title template for GitHub issues
|
|
65
|
+
# The {{ unique_id }} variable is required for duplicate detection
|
|
64
66
|
title: "custom_title_template.liquid"
|
|
65
67
|
body: "custom_body_template.liquid"
|
|
66
68
|
|
|
69
|
+
# Unique identifier template for duplicate detection
|
|
70
|
+
# This is rendered and used to search for existing issues
|
|
71
|
+
# Default: "[{{ stage | upcase }}] {{ comment_id }}"
|
|
72
|
+
# The unique_id is also available as {{ unique_id }} in title/body templates
|
|
73
|
+
unique_id: "[{{ stage | upcase }}] {{ comment_id }}"
|
|
74
|
+
|
|
67
75
|
# Retrieval configuration for github-retrieve command
|
|
68
76
|
retrieval:
|
|
69
77
|
# Magic comment markers to look for in GitHub issue comments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# {% if stage %}[{{ stage | upcase }}] {% endif %}{% if document %}{{ document }}
|
|
1
|
+
# {% if stage %}[{{ stage | upcase }}] {% endif %}{{ comment_id }} {% if document %}({{ document }}){% endif %}
|
|
2
2
|
|
|
3
3
|
**Stage:** {{ stage | default: "Not specified" }}
|
|
4
4
|
**Document:** {{ document | default: "Not specified" }}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{
|
|
1
|
+
{{ unique_id }}: {{ brief_summary }} {% if document %}({{ document }}){% endif %}
|
data/lib/commenter/cli.rb
CHANGED
|
@@ -33,7 +33,10 @@ module Commenter
|
|
|
33
33
|
schema_target = File.join(schema_dir, "iso_comment_2012-03.yaml")
|
|
34
34
|
|
|
35
35
|
# Only copy if source and target are different
|
|
36
|
-
|
|
36
|
+
unless File.expand_path(schema_source) == File.expand_path(schema_target)
|
|
37
|
+
FileUtils.cp(schema_source,
|
|
38
|
+
schema_target)
|
|
39
|
+
end
|
|
37
40
|
|
|
38
41
|
puts "Converted #{input_docx} to #{output_yaml}"
|
|
39
42
|
puts "Schema file created at #{schema_target}"
|
data/lib/commenter/comment.rb
CHANGED
|
@@ -11,13 +11,22 @@ module Commenter
|
|
|
11
11
|
@id = attrs[:id]
|
|
12
12
|
@body = attrs[:body]
|
|
13
13
|
@locality = symbolize_keys(attrs[:locality] || {})
|
|
14
|
-
@type = attrs[:type]
|
|
14
|
+
@type = expand_comment_type(attrs[:type])
|
|
15
15
|
@comments = attrs[:comments]
|
|
16
16
|
@proposed_change = attrs[:proposed_change]
|
|
17
17
|
@observations = attrs[:observations]
|
|
18
18
|
@github = symbolize_keys(attrs[:github] || {})
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def expand_comment_type(type)
|
|
22
|
+
case type&.downcase
|
|
23
|
+
when "ge" then "general"
|
|
24
|
+
when "te" then "technical"
|
|
25
|
+
when "ed" then "editorial"
|
|
26
|
+
else type
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
def line_number
|
|
22
31
|
@locality[:line_number]
|
|
23
32
|
end
|
|
@@ -16,6 +16,7 @@ module Commenter
|
|
|
16
16
|
|
|
17
17
|
@title_template = load_liquid_template(title_template_path || default_title_template_path)
|
|
18
18
|
@body_template = load_liquid_template(body_template_path || default_body_template_path)
|
|
19
|
+
@unique_id_template = load_unique_id_template
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def create_issues_from_yaml(yaml_file, options = {})
|
|
@@ -70,7 +71,26 @@ module Commenter
|
|
|
70
71
|
raise "Template file not found: #{template_path}"
|
|
71
72
|
end
|
|
72
73
|
|
|
74
|
+
def load_unique_id_template
|
|
75
|
+
unique_id_config = @config.dig("github", "templates", "unique_id")
|
|
76
|
+
|
|
77
|
+
if unique_id_config
|
|
78
|
+
# Check if it's a file path or inline template
|
|
79
|
+
if File.exist?(unique_id_config)
|
|
80
|
+
load_liquid_template(unique_id_config)
|
|
81
|
+
else
|
|
82
|
+
Liquid::Template.parse(unique_id_config)
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
# Default unique_id pattern: "[STAGE] COMMENT_ID"
|
|
86
|
+
Liquid::Template.parse("[{{ stage | upcase }}] {{ comment_id }}")
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
73
90
|
def template_variables(comment, comment_sheet)
|
|
91
|
+
# Render unique_id first so it can be used in other templates
|
|
92
|
+
unique_id = render_unique_id(comment, comment_sheet)
|
|
93
|
+
|
|
74
94
|
{
|
|
75
95
|
# Comment sheet variables
|
|
76
96
|
"stage" => comment_sheet.stage || "",
|
|
@@ -95,17 +115,30 @@ module Commenter
|
|
|
95
115
|
"line_number" => comment.line_number || "",
|
|
96
116
|
|
|
97
117
|
# Computed variables
|
|
118
|
+
"unique_id" => unique_id,
|
|
98
119
|
"has_observations" => !comment.observations.nil? && !comment.observations.strip.empty?,
|
|
99
120
|
"has_proposed_change" => !comment.proposed_change.nil? && !comment.proposed_change.strip.empty?,
|
|
100
121
|
"locality_summary" => format_locality(comment)
|
|
101
122
|
}
|
|
102
123
|
end
|
|
103
124
|
|
|
125
|
+
def render_unique_id(comment, comment_sheet)
|
|
126
|
+
base_variables = {
|
|
127
|
+
"stage" => comment_sheet.stage || "",
|
|
128
|
+
"document" => comment_sheet.document || "",
|
|
129
|
+
"project" => comment_sheet.project || "",
|
|
130
|
+
"comment_id" => comment.id || "",
|
|
131
|
+
"body" => comment.body || "",
|
|
132
|
+
"type" => comment.type || ""
|
|
133
|
+
}
|
|
134
|
+
@unique_id_template.render(base_variables).strip
|
|
135
|
+
end
|
|
136
|
+
|
|
104
137
|
def expand_comment_type(type)
|
|
105
138
|
case type&.downcase
|
|
106
|
-
when "ge" then "General"
|
|
107
|
-
when "te" then "Technical"
|
|
108
|
-
when "ed" then "Editorial"
|
|
139
|
+
when "ge", "general" then "General"
|
|
140
|
+
when "te", "technical" then "Technical"
|
|
141
|
+
when "ed", "editorial" then "Editorial"
|
|
109
142
|
else type || "Unknown"
|
|
110
143
|
end
|
|
111
144
|
end
|
|
@@ -119,9 +152,11 @@ module Commenter
|
|
|
119
152
|
end
|
|
120
153
|
|
|
121
154
|
def create_issue(comment, comment_sheet, options = {})
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
puts "[GitHubIssueCreator] Creating issue for comment ID: #{comment.id}"
|
|
156
|
+
# Check if issue already exists (stage-aware)
|
|
157
|
+
existing_issue = find_existing_issue(comment, comment_sheet)
|
|
124
158
|
if existing_issue
|
|
159
|
+
puts "[GitHubIssueCreator] Issue already exists for comment ID: #{comment.id} at stage #{comment_sheet.stage}, skipping creation."
|
|
125
160
|
return {
|
|
126
161
|
comment_id: comment.id,
|
|
127
162
|
status: :skipped,
|
|
@@ -139,8 +174,10 @@ module Commenter
|
|
|
139
174
|
milestone: determine_milestone(comment, comment_sheet, options)
|
|
140
175
|
}.compact
|
|
141
176
|
|
|
177
|
+
puts "[GitHubIssueCreator] Creating issue with title: #{title}"
|
|
142
178
|
begin
|
|
143
179
|
issue = @github_client.create_issue(@repo, title, body, issue_options)
|
|
180
|
+
puts "[GitHubIssueCreator] Issue created successfully: #{issue.html_url}"
|
|
144
181
|
{
|
|
145
182
|
comment_id: comment.id,
|
|
146
183
|
status: :created,
|
|
@@ -148,6 +185,7 @@ module Commenter
|
|
|
148
185
|
issue_url: issue.html_url
|
|
149
186
|
}
|
|
150
187
|
rescue Octokit::Error => e
|
|
188
|
+
puts "[GitHubIssueCreator] Error creating issue for comment ID: #{comment.id} - #{e.message}"
|
|
151
189
|
{
|
|
152
190
|
comment_id: comment.id,
|
|
153
191
|
status: :error,
|
|
@@ -157,6 +195,8 @@ module Commenter
|
|
|
157
195
|
end
|
|
158
196
|
|
|
159
197
|
def preview_issue(comment, comment_sheet)
|
|
198
|
+
puts "[GitHubIssueCreator] Previewing issue for comment ID: #{comment.id}"
|
|
199
|
+
|
|
160
200
|
title = @title_template.render(template_variables(comment, comment_sheet))
|
|
161
201
|
body = @body_template.render(template_variables(comment, comment_sheet))
|
|
162
202
|
|
|
@@ -170,9 +210,13 @@ module Commenter
|
|
|
170
210
|
}
|
|
171
211
|
end
|
|
172
212
|
|
|
173
|
-
def find_existing_issue(comment)
|
|
174
|
-
|
|
175
|
-
|
|
213
|
+
def find_existing_issue(comment, comment_sheet)
|
|
214
|
+
unique_id = render_unique_id(comment, comment_sheet)
|
|
215
|
+
puts "[GitHubIssueCreator] Searching for existing issue with unique_id: #{unique_id}"
|
|
216
|
+
|
|
217
|
+
# Search for existing issues with the unique_id in the title
|
|
218
|
+
# The unique_id is configurable and defaults to "[STAGE] COMMENT_ID"
|
|
219
|
+
query = "repo:#{@repo} in:title \"#{unique_id}\""
|
|
176
220
|
results = @github_client.search_issues(query)
|
|
177
221
|
results.items.first
|
|
178
222
|
rescue Octokit::Error
|
|
@@ -212,26 +256,25 @@ module Commenter
|
|
|
212
256
|
assignees.compact.uniq
|
|
213
257
|
end
|
|
214
258
|
|
|
215
|
-
def determine_milestone(_comment,
|
|
216
|
-
# Check for
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
#
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return milestone_number if milestone_number
|
|
225
|
-
end
|
|
226
|
-
end
|
|
259
|
+
def determine_milestone(_comment, _comment_sheet, _options)
|
|
260
|
+
# # Check for stage-specific milestone
|
|
261
|
+
# if comment_sheet.stage
|
|
262
|
+
# stage_milestone = @config.dig("github", "stage_milestones", comment_sheet.stage)
|
|
263
|
+
# if stage_milestone
|
|
264
|
+
# milestone_number = resolve_milestone_by_name_or_number(stage_milestone)
|
|
265
|
+
# return milestone_number if milestone_number
|
|
266
|
+
# end
|
|
267
|
+
# end
|
|
227
268
|
|
|
228
269
|
# Use configured milestone
|
|
229
270
|
milestone_config = @config.dig("github", "milestone")
|
|
230
271
|
return nil unless milestone_config
|
|
231
272
|
|
|
232
273
|
if milestone_config["number"]
|
|
274
|
+
puts "[GitHubIssueCreator] Using milestone number: #{milestone_config["number"]}"
|
|
233
275
|
milestone_config["number"]
|
|
234
276
|
elsif milestone_config["name"]
|
|
277
|
+
puts "[GitHubIssueCreator] Using milestone name: #{milestone_config["name"]}"
|
|
235
278
|
resolve_milestone_by_name_or_number(milestone_config["name"])
|
|
236
279
|
end
|
|
237
280
|
end
|
|
@@ -246,6 +289,8 @@ module Commenter
|
|
|
246
289
|
|
|
247
290
|
def find_milestone_by_name(name)
|
|
248
291
|
milestones = @github_client.milestones(@repo, state: "all")
|
|
292
|
+
|
|
293
|
+
puts "[GitHubIssueCreator] Found #{milestones.size} milestones in repository #{@repo}" if milestones.any?
|
|
249
294
|
milestone = milestones.find { |m| m.title == name }
|
|
250
295
|
milestone&.number
|
|
251
296
|
rescue Octokit::Error
|
|
@@ -411,7 +456,8 @@ module Commenter
|
|
|
411
456
|
end
|
|
412
457
|
|
|
413
458
|
# Fallback to last comment if configured and no magic comment found
|
|
414
|
-
return comments.last.body.strip if @config.dig("github", "retrieval",
|
|
459
|
+
return comments.last.body.strip if @config.dig("github", "retrieval",
|
|
460
|
+
"fallback_to_last_comment") && !comments.empty?
|
|
415
461
|
|
|
416
462
|
nil
|
|
417
463
|
rescue Octokit::Error
|
data/lib/commenter/version.rb
CHANGED
|
@@ -22,7 +22,7 @@ RSpec.describe Commenter::Comment do
|
|
|
22
22
|
expect(comment.clause).to eq("5.1")
|
|
23
23
|
expect(comment.element).to eq("Table 1")
|
|
24
24
|
expect(comment.line_number).to eq("42")
|
|
25
|
-
expect(comment.type).to eq("
|
|
25
|
+
expect(comment.type).to eq("technical")
|
|
26
26
|
expect(comment.comments).to eq("Test comment")
|
|
27
27
|
expect(comment.proposed_change).to eq("Test change")
|
|
28
28
|
expect(comment.observations).to eq("Test observations")
|
|
@@ -173,7 +173,7 @@ RSpec.describe Commenter::Comment do
|
|
|
173
173
|
expect(hash[:id]).to eq("US-001")
|
|
174
174
|
expect(hash[:body]).to eq("US")
|
|
175
175
|
expect(hash[:locality][:clause]).to eq("5.1")
|
|
176
|
-
expect(hash[:type]).to eq("
|
|
176
|
+
expect(hash[:type]).to eq("technical")
|
|
177
177
|
expect(hash[:comments]).to eq("Test")
|
|
178
178
|
expect(hash[:proposed_change]).to eq("Change")
|
|
179
179
|
expect(hash[:observations]).to eq("Obs")
|
|
@@ -120,7 +120,7 @@ RSpec.describe Commenter::GitHubIssueCreator do
|
|
|
120
120
|
expect(result[:title]).to eq("US-001: Clause 5.1, Table 1: Test comment text")
|
|
121
121
|
expect(result[:body]).to include("Comment: Test comment text")
|
|
122
122
|
expect(result[:body]).to include("Type: Technical")
|
|
123
|
-
expect(result[:labels]).to include("comment-review", "draft-international-standard", "
|
|
123
|
+
expect(result[:labels]).to include("comment-review", "draft-international-standard", "technical")
|
|
124
124
|
expect(result[:assignees]).to eq(["test-assignee"])
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -144,7 +144,7 @@ RSpec.describe Commenter::GitHubIssueCreator do
|
|
|
144
144
|
expect(variables["stage"]).to eq("DIS")
|
|
145
145
|
expect(variables["document"]).to eq("Test Document")
|
|
146
146
|
expect(variables["comment_id"]).to eq("US-001")
|
|
147
|
-
expect(variables["type"]).to eq("
|
|
147
|
+
expect(variables["type"]).to eq("technical")
|
|
148
148
|
expect(variables["type_full_name"]).to eq("Technical")
|
|
149
149
|
expect(variables["clause"]).to eq("5.1")
|
|
150
150
|
expect(variables["element"]).to eq("Table 1")
|
|
@@ -164,7 +164,7 @@ RSpec.describe Commenter::GitHubIssueCreator do
|
|
|
164
164
|
|
|
165
165
|
expect(labels).to include("comment-review") # default
|
|
166
166
|
expect(labels).to include("draft-international-standard") # stage-specific
|
|
167
|
-
expect(labels).to include("
|
|
167
|
+
expect(labels).to include("technical") # comment type (expanded)
|
|
168
168
|
expect(labels.uniq).to eq(labels) # no duplicates
|
|
169
169
|
end
|
|
170
170
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commenter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|