Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
# pull_request:
# types: [opened, synchronize]
# # Optional: Only run on specific file changes
# # paths:
# # - "src/**/*.ts"
# # - "src/**/*.tsx"
# # - "src/**/*.js"
# # - "src/**/*.jsx"
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
workflow_dispatch:

jobs:

Expand Down
20 changes: 18 additions & 2 deletions internal/config/loader_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@ import (
func withTempHome(t *testing.T) (restore func(), tempHome string) {
t.Helper()
dir := t.TempDir()

// On Windows, os.UserHomeDir() resolves the home directory by checking USERPROFILE first, then falling back to HOMEDRIVE+HOMEPATH. It only checks HOME as a last resort.
oldHome := os.Getenv("HOME")
// On Windows, Cobra/Go may rely on USERPROFILE, but this repo is Linux oriented.
oldUserProfile := os.Getenv("USERPROFILE")

os.Setenv("HOME", dir)
return func() { os.Setenv("HOME", oldHome) }, dir
os.Setenv("USERPROFILE", dir)

restoreEnv := func(key, val string) {
if val == "" {
os.Unsetenv(key)
} else {
os.Setenv(key, val)
}
}

return func() {
restoreEnv("HOME", oldHome)
restoreEnv("USERPROFILE", oldUserProfile)
}, dir
}

func TestCreateOrReadConfigs_CreatesWhenMissingAndWritesFile(t *testing.T) {
Expand Down
9 changes: 7 additions & 2 deletions internal/config/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package config

import "os"

// Config holds all runtime options used by reposcan.
// Values may come from a config file and/or be overridden by CLI flags.
type Config struct {
Expand All @@ -21,10 +23,13 @@ type Config struct {
// Defaults returns a Config populated with sensible defaults suitable for
// typical local development machines.
func Defaults() Config {
//home, err := os.UserHomeDir()
home, err := os.UserHomeDir()
if err != nil {
home = ""
}

var roots []string = nil
roots = []string{"$HOME"}
roots = []string{home}

defaultDirIgnore := []string{
// --- Package managers / deps ---
Expand Down
20 changes: 6 additions & 14 deletions internal/render/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package file
import (
"encoding/json"
"errors"
"fmt"
"path/filepath"

"github.com/mabd-dev/reposcan/internal/utils"
"github.com/mabd-dev/reposcan/pkg/report"
"strings"
)

// WriteScanReport writes the given ScanReport as a JSON file into dirPath.
Expand All @@ -21,18 +23,8 @@ func WriteScanReport(
return errors.New(msg)
}

var sBuilder strings.Builder
sBuilder.WriteString(dirPath)
if !strings.HasSuffix(dirPath, "/") {
sBuilder.WriteString("/")
}

sBuilder.WriteString("ScanReport ")

datetime := report.GeneratedAt.Format("2006-01-02 15:04:05")
sBuilder.WriteString(datetime)

sBuilder.WriteString(".json")
reportFileName := fmt.Sprintf("ScanReport %s.json", report.GeneratedAt.Format("2006-01-02 15-04-05"))
fullReportPath := filepath.Join(dirPath, reportFileName)

return utils.WriteToFile(jsonReport, sBuilder.String())
return utils.WriteToFile(jsonReport, fullReportPath)
}
Loading