Skip to content

Commit

Permalink
fix(softfloat/gen): add gitRoot function to determine repository root…
Browse files Browse the repository at this point in the history
… path
  • Loading branch information
omarsy committed Jan 26, 2025
1 parent ae874a2 commit b97341a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions gnovm/pkg/gnolang/internal/softfloat/gen/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -82,10 +83,29 @@ func processSoftFloat64TestFile() {
}
}

func gitRoot() (string, error) {
wd, err := os.Getwd()
if err != nil {
return "", err
}
p := wd
for {
if s, e := os.Stat(filepath.Join(p, ".git")); e == nil && s.IsDir() {
return p, nil
}

if strings.HasSuffix(p, string(filepath.Separator)) {
return "", errors.New("root git not found")
}

p = filepath.Dir(p)
}
}

func gofumpt() {
rootPath, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
rootPath, err := gitRoot()
if err != nil {
log.Fatal("error git rev-parse:", err)
log.Fatal("error finding git root:", err)
}

cmd := exec.Command("go", "run", "-modfile", filepath.Join(strings.TrimSpace(string(rootPath)), "misc/devdeps/go.mod"), "mvdan.cc/gofumpt", "-w", ".")

Check failure on line 111 in gnovm/pkg/gnolang/internal/softfloat/gen/main.go

View workflow job for this annotation

GitHub Actions / Run GnoVM suite / Go Lint / lint

unnecessary conversion (unconvert)
Expand Down

0 comments on commit b97341a

Please sign in to comment.