From 61aed81f0bba52a1102982837137a80413c2e7f2 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Mon, 4 Nov 2024 15:11:58 +0100 Subject: [PATCH] .. --- acceptance/main.go | 2 +- acceptance/shim.js | 2 +- acceptance/todos/finder.go | 20 ++++++++++---------- acceptance/todos/finder_test.go | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/acceptance/main.go b/acceptance/main.go index eca1464..e499c3e 100644 --- a/acceptance/main.go +++ b/acceptance/main.go @@ -59,7 +59,7 @@ func (a *acceptance) syncTodos(ctx context.Context) error { if err != nil { return fmt.Errorf("tech debt: %w", err) } - err = techDebt.Create(ctx) + err = techDebt.CreateIssues(ctx) if err != nil { return fmt.Errorf("create: %w", err) } diff --git a/acceptance/shim.js b/acceptance/shim.js index 77d8f29..99ae758 100644 --- a/acceptance/shim.js +++ b/acceptance/shim.js @@ -1,4 +1,4 @@ -const version = 'v0.3.1'; +const version = 'v0.4.0'; const action = 'acceptance'; const { createWriteStream, chmodSync } = require('fs'); diff --git a/acceptance/todos/finder.go b/acceptance/todos/finder.go index 58d9a43..08cbfb1 100644 --- a/acceptance/todos/finder.go +++ b/acceptance/todos/finder.go @@ -13,7 +13,7 @@ import ( "github.com/databrickslabs/sandbox/go-libs/github" ) -func New(ctx context.Context, gh *github.GitHubClient, root string) (*Finder, error) { +func New(ctx context.Context, gh *github.GitHubClient, root string) (*TechnicalDebtFinder, error) { fs, err := fileset.RecursiveChildren(root) if err != nil { return nil, fmt.Errorf("fileset: %w", err) @@ -35,14 +35,14 @@ func New(ctx context.Context, gh *github.GitHubClient, root string) (*Finder, er if err != nil { return nil, fmt.Errorf("git: %w", err) } - return &Finder{ + return &TechnicalDebtFinder{ fs: scope, git: checkout, gh: gh, }, nil } -type Finder struct { +type TechnicalDebtFinder struct { fs fileset.FileSet git *git.Checkout gh *github.GitHubClient @@ -53,7 +53,7 @@ type Todo struct { link string } -func (f *Finder) Create(ctx context.Context) error { +func (f *TechnicalDebtFinder) CreateIssues(ctx context.Context) error { todos, err := f.allTodos(ctx) if err != nil { return fmt.Errorf("all todos: %w", err) @@ -73,7 +73,7 @@ func (f *Finder) Create(ctx context.Context) error { return nil } -func (f *Finder) createIssue(ctx context.Context, todo Todo) error { +func (f *TechnicalDebtFinder) createIssue(ctx context.Context, todo Todo) error { org, repo, ok := f.git.OrgAndRepo() if !ok { return fmt.Errorf("git org and repo") @@ -89,7 +89,7 @@ func (f *Finder) createIssue(ctx context.Context, todo Todo) error { return nil } -func (f *Finder) seenIssues(ctx context.Context) (map[string]bool, error) { +func (f *TechnicalDebtFinder) seenIssues(ctx context.Context) (map[string]bool, error) { org, repo, ok := f.git.OrgAndRepo() if !ok { return nil, fmt.Errorf("git org and repo") @@ -113,8 +113,8 @@ func (f *Finder) seenIssues(ctx context.Context) (map[string]bool, error) { return seen, nil } -func (f *Finder) allTodos(ctx context.Context) ([]Todo, error) { - prefix, err := f.prefix(ctx) +func (f *TechnicalDebtFinder) allTodos(ctx context.Context) ([]Todo, error) { + prefix, err := f.embedPrefix(ctx) if err != nil { return nil, fmt.Errorf("prefix: %w", err) } @@ -139,7 +139,7 @@ func (f *Finder) allTodos(ctx context.Context) ([]Todo, error) { return todos, nil } -func (f *Finder) prefix(ctx context.Context) (string, error) { +func (f *TechnicalDebtFinder) embedPrefix(ctx context.Context) (string, error) { org, repo, ok := f.git.OrgAndRepo() if !ok { return "", fmt.Errorf("git org and repo") @@ -149,6 +149,6 @@ func (f *Finder) prefix(ctx context.Context) (string, error) { return "", fmt.Errorf("git history: %w", err) } // example: https://github.com/databrickslabs/ucx/blob/69a0cf8ce3450680dc222150f500d84a1eb523fc/src/databricks/labs/ucx/azure/access.py#L25-L35 - prefix := fmt.Sprintf("https://github.com/%s/%s/blob/%s", org, repo, commits[0].Sha) + prefix := fmt.Sprintf("https://github.com/%s/%s/blame/%s", org, repo, commits[0].Sha) return prefix, nil } diff --git a/acceptance/todos/finder_test.go b/acceptance/todos/finder_test.go index f855104..ec35822 100644 --- a/acceptance/todos/finder_test.go +++ b/acceptance/todos/finder_test.go @@ -9,12 +9,13 @@ import ( ) func TestXXX(t *testing.T) { + t.SkipNow() ctx := context.Background() gh := github.NewClient(&github.GitHubConfig{}) f, err := New(ctx, gh, "/Users/serge.smertin/git/labs/remorph") assert.NoError(t, err) - err = f.Create(ctx) + err = f.CreateIssues(ctx) assert.NoError(t, err) }