Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 079008c

Browse files
committed
Improve error messages
1 parent ed5cff0 commit 079008c

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

lib/git/pkgs/commands/blame.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def run
2121
branch_name = @options[:branch] || repo.default_branch
2222
branch = Models::Branch.find_by(name: branch_name)
2323

24-
error "No analysis found for branch '#{branch_name}'" unless branch&.last_analyzed_sha
24+
error "No analysis found for branch '#{branch_name}'. Run 'git pkgs init' first." unless branch&.last_analyzed_sha
2525

2626
current_commit = Models::Commit.find_by(sha: branch.last_analyzed_sha)
2727
snapshots = current_commit&.dependency_snapshots&.includes(:manifest) || []

lib/git/pkgs/commands/branch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_branch
4040

4141
Database.connect(repo.git_dir)
4242

43-
error "Branch '#{branch_name}' not found" unless repo.branch_exists?(branch_name)
43+
error "Branch '#{branch_name}' not found. Check 'git branch -a' for available branches." unless repo.branch_exists?(branch_name)
4444

4545
existing = Models::Branch.find_by(name: branch_name)
4646
if existing
@@ -104,7 +104,7 @@ def remove_branch
104104
Database.connect(repo.git_dir)
105105

106106
branch = Models::Branch.find_by(name: branch_name)
107-
error "Branch '#{branch_name}' not tracked" unless branch
107+
error "Branch '#{branch_name}' not tracked. Run 'git pkgs branch list' to see tracked branches." unless branch
108108

109109
# Only delete branch_commits, keep shared commits
110110
count = branch.branch_commits.count

lib/git/pkgs/commands/diff.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def run
2727
from_sha = repo.rev_parse(from_ref)
2828
to_sha = repo.rev_parse(to_ref)
2929

30-
error "Could not resolve '#{from_ref}'" unless from_sha
31-
error "Could not resolve '#{to_ref}'" unless to_sha
30+
error "Could not resolve '#{from_ref}'. Check that the ref exists." unless from_sha
31+
error "Could not resolve '#{to_ref}'. Check that the ref exists." unless to_sha
3232

3333
from_commit = Models::Commit.find_or_create_from_repo(repo, from_sha)
3434
to_commit = Models::Commit.find_or_create_from_repo(repo, to_sha)
3535

36-
error "Commit '#{from_sha[0..7]}' not found" unless from_commit
37-
error "Commit '#{to_sha[0..7]}' not found" unless to_commit
36+
error "Commit '#{from_sha[0..7]}' not in database. Run 'git pkgs update' to index new commits." unless from_commit
37+
error "Commit '#{to_sha[0..7]}' not in database. Run 'git pkgs update' to index new commits." unless to_commit
3838

3939
# Get all changes between the two commits
4040
changes = Models::DependencyChange

lib/git/pkgs/commands/init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def run
1818
repo = Repository.new
1919

2020
branch_name = @options[:branch] || repo.default_branch
21-
error "Branch '#{branch_name}' not found" unless repo.branch_exists?(branch_name)
21+
error "Branch '#{branch_name}' not found. Check 'git branch -a' for available branches." unless repo.branch_exists?(branch_name)
2222

2323
if Database.exists?(repo.git_dir) && !@options[:force]
2424
info "Database already exists. Use --force to rebuild."

lib/git/pkgs/commands/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run
2020
commit_sha = @options[:commit] || repo.head_sha
2121
target_commit = Models::Commit.find_by(sha: commit_sha)
2222

23-
error "Commit #{commit_sha[0, 7]} not found in database" unless target_commit
23+
error "Commit #{commit_sha[0, 7]} not in database. Run 'git pkgs update' to index new commits." unless target_commit
2424

2525
deps = compute_dependencies_at_commit(target_commit, repo)
2626

lib/git/pkgs/commands/show.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def run
2020
Database.connect(repo.git_dir)
2121

2222
sha = repo.rev_parse(ref)
23-
error "Could not resolve '#{ref}'" unless sha
23+
error "Could not resolve '#{ref}'. Check that the ref exists with 'git rev-parse #{ref}'." unless sha
2424

2525
commit = Models::Commit.find_or_create_from_repo(repo, sha)
26-
error "Commit '#{sha[0..7]}' not found" unless commit
26+
error "Commit '#{sha[0..7]}' not in database. Run 'git pkgs update' to index new commits." unless commit
2727

2828
changes = Models::DependencyChange
2929
.includes(:commit, :manifest)

lib/git/pkgs/commands/stale.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run
2020
branch_name = @options[:branch] || repo.default_branch
2121
branch = Models::Branch.find_by(name: branch_name)
2222

23-
error "No analysis found for branch '#{branch_name}'" unless branch&.last_analyzed_sha
23+
error "No analysis found for branch '#{branch_name}'. Run 'git pkgs init' first." unless branch&.last_analyzed_sha
2424

2525
current_commit = Models::Commit.find_by(sha: branch.last_analyzed_sha)
2626
snapshots = current_commit&.dependency_snapshots&.includes(:manifest) || []

lib/git/pkgs/commands/tree.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def run
2121
commit_sha = @options[:commit] || repo.head_sha
2222
commit = find_commit_with_snapshot(commit_sha, repo)
2323

24-
error "No dependency data found for commit #{commit_sha[0, 7]}" unless commit
24+
error "No dependency data for commit #{commit_sha[0, 7]}. Run 'git pkgs update' to index new commits." unless commit
2525

2626
# Get current snapshots
2727
snapshots = commit.dependency_snapshots.includes(:manifest)

lib/git/pkgs/output.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Output
1212
def parse_time(str)
1313
Time.parse(str)
1414
rescue ArgumentError
15-
error "Invalid date format: #{str}"
15+
error "Invalid date format: #{str}. Use YYYY-MM-DD format."
1616
end
1717

1818
# Print informational/status message. Suppressed in quiet mode.

0 commit comments

Comments
 (0)