@@ -51,6 +51,7 @@ type TechnicalDebtFinder struct {
51
51
type Todo struct {
52
52
message string
53
53
link string
54
+ blame string
54
55
}
55
56
56
57
func (f * TechnicalDebtFinder ) CreateIssues (ctx context.Context ) error {
@@ -80,7 +81,7 @@ func (f *TechnicalDebtFinder) createIssue(ctx context.Context, todo Todo) error
80
81
}
81
82
_ , err := f .gh .CreateIssue (ctx , org , repo , github.NewIssue {
82
83
Title : fmt .Sprintf ("[TODO] %s" , todo .message ),
83
- Body : fmt .Sprintf ("See: %s" , todo .link ),
84
+ Body : fmt .Sprintf ("See [more context](%s): \n %s" , todo . blame , todo .link ),
84
85
Labels : []string {"tech debt" },
85
86
})
86
87
if err != nil {
@@ -121,6 +122,9 @@ func (f *TechnicalDebtFinder) allTodos(ctx context.Context) ([]Todo, error) {
121
122
var todos []Todo
122
123
needle := regexp .MustCompile (`TODO:(.*)` )
123
124
for _ , v := range f .fs {
125
+ if ! strings .HasSuffix (v .Absolute , v .Relative ) {
126
+ continue // avoid false positives like https://github.com/databrickslabs/ucx/issues/3193
127
+ }
124
128
raw , err := v .Raw ()
125
129
if err != nil {
126
130
return nil , fmt .Errorf ("%s: %w" , v .Relative , err )
@@ -130,9 +134,11 @@ func (f *TechnicalDebtFinder) allTodos(ctx context.Context) ([]Todo, error) {
130
134
if ! needle .MatchString (line ) {
131
135
continue
132
136
}
137
+ link := fmt .Sprintf ("%s/%s#L%d-L%d" , prefix , v .Relative , i , i + 5 )
133
138
todos = append (todos , Todo {
134
139
message : strings .TrimSpace (needle .FindStringSubmatch (line )[1 ]),
135
- link : fmt .Sprintf ("%s/%s#L%d-L%d" , prefix , v .Relative , i , i + 5 ),
140
+ link : link ,
141
+ blame : strings .ReplaceAll (link , "/blob/" , "/blame/" ),
136
142
})
137
143
}
138
144
}
@@ -149,6 +155,6 @@ func (f *TechnicalDebtFinder) embedPrefix(ctx context.Context) (string, error) {
149
155
return "" , fmt .Errorf ("git history: %w" , err )
150
156
}
151
157
// example: https://github.com/databrickslabs/ucx/blob/69a0cf8ce3450680dc222150f500d84a1eb523fc/src/databricks/labs/ucx/azure/access.py#L25-L35
152
- prefix := fmt .Sprintf ("https://github.com/%s/%s/blame /%s" , org , repo , commits [0 ].Sha )
158
+ prefix := fmt .Sprintf ("https://github.com/%s/%s/blob /%s" , org , repo , commits [0 ].Sha )
153
159
return prefix , nil
154
160
}
0 commit comments