Skip to content

Commit 9721f6a

Browse files
committed
...
1 parent 61aed81 commit 9721f6a

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

acceptance/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ func run(ctx context.Context, opts ...githubactions.Option) error {
3535
return fmt.Errorf("boilerplate: %w", err)
3636
}
3737
a := &acceptance{Boilerplate: b}
38-
err = a.syncTodos(ctx)
39-
if err != nil {
40-
return fmt.Errorf("sync todos: %w", err)
41-
}
4238
alert, err := a.trigger(ctx)
4339
if err != nil {
4440
return fmt.Errorf("trigger: %w", err)
@@ -163,6 +159,12 @@ func (a *acceptance) notifyIfNeeded(ctx context.Context, alert *notify.Notificat
163159
}
164160
}
165161
if needsIssues {
162+
// doesn't seem to pick the right commit hash, so it's better to do it nightly
163+
// see https://github.com/databrickslabs/ucx/issues/3195
164+
err := a.syncTodos(ctx)
165+
if err != nil {
166+
return fmt.Errorf("sync todos: %w", err)
167+
}
166168
for _, v := range alert.Report {
167169
if !v.Failed() {
168170
continue

acceptance/shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const version = 'v0.4.0';
1+
const version = 'v0.4.1';
22
const action = 'acceptance';
33

44
const { createWriteStream, chmodSync } = require('fs');

acceptance/todos/finder.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type TechnicalDebtFinder struct {
5151
type Todo struct {
5252
message string
5353
link string
54+
blame string
5455
}
5556

5657
func (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

Comments
 (0)