Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx committed Nov 4, 2024
1 parent cbab0cf commit 61aed81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion acceptance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion acceptance/shim.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const version = 'v0.3.1';
const version = 'v0.4.0';
const action = 'acceptance';

const { createWriteStream, chmodSync } = require('fs');
Expand Down
20 changes: 10 additions & 10 deletions acceptance/todos/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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)
}
Expand All @@ -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")
Expand All @@ -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
}
3 changes: 2 additions & 1 deletion acceptance/todos/finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 61aed81

Please sign in to comment.