Add wsl linter and fix

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-19 14:51:08 +04:00
parent eedfdcecc8
commit 9156d6a16a
882 changed files with 6068 additions and 574 deletions

View File

@@ -68,6 +68,7 @@ func run() error {
}
fmt.Println("done")
return nil
}
@@ -95,6 +96,7 @@ func newPgClientFromDSN(dsn string) (*pg.Client, error) {
if u.Port() == "" {
host = net.JoinHostPort(u.Hostname(), "5432")
}
opts = append(opts, pg.WithAddr(host))
}

View File

@@ -73,6 +73,7 @@ func run() error {
}
var ids []string
err = pgClient.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
rows, err := conn.Query(
ctx,
@@ -94,8 +95,10 @@ ORDER BY id;
if err := rows.Scan(&id); err != nil {
return fmt.Errorf("cannot scan document version id: %w", err)
}
ids = append(ids, id)
}
return rows.Err()
})
if err != nil {
@@ -103,13 +106,16 @@ ORDER BY id;
}
var failures int
for _, idStr := range ids {
if err := migrateOneInTx(ctx, pgClient, idStr, dryRun); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
failures++
if !continueOnError {
return fmt.Errorf("stopped after %d failure(s)", failures)
}
continue
}
}
@@ -119,6 +125,7 @@ ORDER BY id;
}
fmt.Println("done")
return nil
}
@@ -135,6 +142,7 @@ func newPgClientFromDSN(dsn string) (*pg.Client, error) {
if u.Port() == "" {
host = net.JoinHostPort(u.Hostname(), "5432")
}
opts = append(opts, pg.WithAddr(host))
}
@@ -197,6 +205,7 @@ func migrateOne(ctx context.Context, tx pg.Tx, idStr string, dryRun bool) error
}
fmt.Printf("updated %s\n", idStr)
return nil
}
@@ -207,5 +216,6 @@ func isProseMirrorDocJSON(s string) bool {
if err := json.Unmarshal([]byte(s), &probe); err != nil {
return false
}
return probe.Type == "doc"
}

View File

@@ -33,9 +33,11 @@ func main() {
if isNonInteractiveEnv() {
ios.ForceNonInteractive = true
}
if isNoColorEnv() {
ios.ForceNoColor = true
}
ios.ApplyColorProfile()
f := &cmdutil.Factory{
@@ -58,15 +60,19 @@ func isNonInteractiveEnv() bool {
if v := os.Getenv("PROBO_NO_INTERACTIVE"); v == "1" || v == "true" {
return true
}
if v := os.Getenv("CI"); v == "true" || v == "1" {
return true
}
if os.Getenv("DEBIAN_FRONTEND") == "noninteractive" {
return true
}
if os.Getenv("TERM") == "dumb" {
return true
}
return false
}
@@ -74,8 +80,10 @@ func isNoColorEnv() bool {
if _, ok := os.LookupEnv("NO_COLOR"); ok {
return true
}
if os.Getenv("TERM") == "dumb" {
return true
}
return false
}

View File

@@ -30,6 +30,7 @@ var (
func main() {
outputPath := flag.String("output", "/etc/probod/config.yml", "output path for the generated config file")
showVersion := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *showVersion {

View File

@@ -29,6 +29,7 @@ var (
func main() {
impl := probod.New()
unit := unit.NewUnit(impl, "probod", version, env)
err := unit.Run()
if err != nil && err != context.Canceled {
panic(err)