Skip to content

Commit 890b299

Browse files
committed
feat: Enhance path resolution, set current directory as default scan root, and update version to v1.2.0.
1 parent 1d6e6c8 commit 890b299

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Thumbs.db
2424

2525
/materials
2626
demo.gif
27-
demo.tap
27+
demo.tape
2828
git-scope
2929
git-scope-test
30+
git-scope-final

internal/config/config.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ type Config struct {
1717
}
1818

1919
// defaultConfig returns sensible defaults
20+
// By default, scan the current directory so git-scope works out of the box
2021
func defaultConfig() *Config {
21-
home, _ := os.UserHomeDir()
22+
// Get current working directory as default root
23+
cwd, err := os.Getwd()
24+
if err != nil {
25+
// Fallback to home directory if cwd fails
26+
cwd, _ = os.UserHomeDir()
27+
}
28+
2229
return &Config{
23-
Roots: []string{
24-
filepath.Join(home, "code"),
25-
filepath.Join(home, "projects"),
26-
},
30+
Roots: []string{cwd},
2731
Ignore: []string{
2832
"node_modules",
2933
".next",
@@ -62,15 +66,26 @@ func Load(path string) (*Config, error) {
6266
return cfg, nil
6367
}
6468

65-
// expandPath expands ~ to user home directory
69+
// expandPath expands ~ to user home directory and resolves relative paths
6670
func expandPath(path string) string {
71+
// Handle ~ prefix
6772
if strings.HasPrefix(path, "~/") {
6873
home, err := os.UserHomeDir()
6974
if err != nil {
7075
return path
7176
}
72-
return filepath.Join(home, path[2:])
77+
path = filepath.Join(home, path[2:])
78+
}
79+
80+
// Handle "." or relative paths - convert to absolute
81+
if path == "." || !filepath.IsAbs(path) {
82+
absPath, err := filepath.Abs(path)
83+
if err != nil {
84+
return path
85+
}
86+
path = absPath
7387
}
88+
7489
return path
7590
}
7691

internal/scan/scan.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ func ScanRoots(roots, ignore []string) ([]model.Repo, error) {
7777
// Found a .git directory
7878
if d.IsDir() && d.Name() == ".git" {
7979
repoPath := filepath.Dir(path)
80+
81+
// Resolve to absolute path to get proper repo name
82+
// This handles cases where path is "." or relative
83+
absPath, err := filepath.Abs(repoPath)
84+
if err == nil {
85+
repoPath = absPath
86+
}
8087
repoName := filepath.Base(repoPath)
8188

8289
status, serr := gitstatus.Status(repoPath)

internal/tui/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (m Model) renderDashboard() string {
9494

9595
// Header with logo on its own line
9696
logo := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#A78BFA")).Render("git-scope")
97-
version := lipgloss.NewStyle().Foreground(lipgloss.Color("#6B7280")).Render(" v1.0.1")
97+
version := lipgloss.NewStyle().Foreground(lipgloss.Color("#6B7280")).Render(" v1.2.0")
9898
b.WriteString(logo + version)
9999
b.WriteString("\n\n")
100100

0 commit comments

Comments
 (0)