@@ -51,6 +51,7 @@ type TechnicalDebtFinder struct {
5151type Todo struct {
5252 message string
5353 link string
54+ blame string
5455}
5556
5657func (f * TechnicalDebtFinder ) CreateIssues (ctx context.Context ) error {
@@ -80,7 +81,7 @@ func (f *TechnicalDebtFinder) createIssue(ctx context.Context, todo Todo) error
8081 }
8182 _ , err := f .gh .CreateIssue (ctx , org , repo , github.NewIssue {
8283 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 ),
8485 Labels : []string {"tech debt" },
8586 })
8687 if err != nil {
@@ -121,6 +122,9 @@ func (f *TechnicalDebtFinder) allTodos(ctx context.Context) ([]Todo, error) {
121122 var todos []Todo
122123 needle := regexp .MustCompile (`TODO:(.*)` )
123124 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+ }
124128 raw , err := v .Raw ()
125129 if err != nil {
126130 return nil , fmt .Errorf ("%s: %w" , v .Relative , err )
@@ -130,9 +134,11 @@ func (f *TechnicalDebtFinder) allTodos(ctx context.Context) ([]Todo, error) {
130134 if ! needle .MatchString (line ) {
131135 continue
132136 }
137+ link := fmt .Sprintf ("%s/%s#L%d-L%d" , prefix , v .Relative , i , i + 5 )
133138 todos = append (todos , Todo {
134139 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/" ),
136142 })
137143 }
138144 }
@@ -149,6 +155,6 @@ func (f *TechnicalDebtFinder) embedPrefix(ctx context.Context) (string, error) {
149155 return "" , fmt .Errorf ("git history: %w" , err )
150156 }
151157 // 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 )
153159 return prefix , nil
154160}
0 commit comments