git-jump 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfb31c6068e94ef82538f0df322527fec4cd32b1458cf7dd2f62bba076b0371a
4
- data.tar.gz: 46d4763ee56a9b588a96000980f32ec6f828185feaf83ec0ad3f6c5e9c683981
3
+ metadata.gz: 7137fa6fe4eb3b364da1e52979e79428817a7c40d9da2b665cbceea2733f6817
4
+ data.tar.gz: 465f2e0d55117769052efdef1137556b09dcdfdc5a3b52d9f28905ee2b1b019e
5
5
  SHA512:
6
- metadata.gz: 40ad5bdd5b4ba6f5dcbc9f6d51de60e8ebde83fdf58cd8296f95824e64a701be70af974029d9aeed1b3e5073ab2260a8b65a32c8a20cf376d34c560f4ac6fc83
7
- data.tar.gz: 93927a1d2ea2ea154fc051cbef01a7f50926668557a8b083f76c18a942c43d0c87cb8d9c0708e499d4e1cfeb090e04a72fa2b046fe08e9b58e24b9ecb35dcd59
6
+ metadata.gz: 7cec7b19e5210677959c391d0ec8892f9d70616c2952083fdc254b0a4fe9a9d29e0316e51efb7a3377d4408192858743e83d580f3b8e8364f308cde3baf00d21
7
+ data.tar.gz: 7a5137b19d11359c1b115ac9171a75ac3f33d7f17ab9443308b955060abffa3c856042bb1c5a0906ad12683551af59f894167a4bb1aff95fa379b52889411dd3
data/AGENTS.md ADDED
@@ -0,0 +1,22 @@
1
+ # Agent Guidelines for git-jump
2
+
3
+ ## Build/Test/Lint Commands
4
+ - Setup: `bin/setup` or `bundle install`
5
+ - Run all tests: `rake spec` or `bundle exec rspec`
6
+ - Run single test file: `bundle exec rspec spec/path/to/file_spec.rb`
7
+ - Run single test: `bundle exec rspec spec/path/to/file_spec.rb:LINE_NUMBER`
8
+ - Lint: `rake rubocop` or `bundle exec rubocop`
9
+ - Lint autofix: `bundle exec rubocop -a`
10
+ - Default task (tests + lint): `rake`
11
+
12
+ ## Code Style Guidelines
13
+ - **Ruby version**: >= 3.2.0
14
+ - **Frozen string literal**: Add `# frozen_string_literal: true` to top of every .rb file
15
+ - **String literals**: Use double quotes for all strings (enforced by RuboCop)
16
+ - **Imports**: Use `require_relative` for internal files, `require` for gems. Optimize loading via loaders for CLI actions
17
+ - **Naming**: Use snake_case for methods/variables, PascalCase for classes/modules
18
+ - **Documentation**: Class/module documentation comments disabled (no need for YARD-style docs)
19
+ - **Error handling**: Return false for errors in actions, output error messages via `output.error()`
20
+ - **Dependencies**: All actions inherit from `Actions::Base`, accept `config:`, `database:`, `repository:`, `output:` kwargs
21
+ - **Tests**: Use RSpec with `subject(:action)`, `let` helpers, and `instance_double` for mocking. Setup git repos in temp dirs
22
+ - **Modules**: Namespace everything under `GitJump` or `GitJump::Actions`, `GitJump::Utils`, etc.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2025-12-12
4
+
5
+ ### Fixed
6
+ - Fixed post-checkout hook to work correctly across all projects
7
+ - Hook now properly requires 'git_jump/hooks/post_checkout' instead of 'git_jump'
8
+ - Added missing dependency requires to post_checkout.rb (Repository, Config, Database)
9
+ - Added missing require for Utils::XDG in config.rb
10
+ - Hook now respects .ruby-version files in repositories
11
+ - Fixed install_loader to include Database dependency
12
+
13
+ ### Added
14
+ - Comprehensive test suite for post-checkout hook (17 tests)
15
+ - Tests for branch tracking, project creation, error handling
16
+ - Hook template validation tests
17
+ - Dependency loading verification tests
18
+ - Added loader tests to ensure all dependencies are properly loaded (6 tests)
19
+ - Added local testing documentation in docs/local-testing.md
20
+
21
+ ### Changed
22
+ - Improved code quality by fixing all RuboCop offenses
23
+ - Extracted helper methods in specs for better maintainability
24
+
25
+ ## [0.1.2] - 2025-11-16
26
+
27
+ ### Fixed
28
+ - Fixed setup action error handling and loader dependencies
29
+
3
30
  ## [0.1.1] - 2025-11-16
4
31
 
5
32
  ### Changed
@@ -0,0 +1,187 @@
1
+ # Testing git-jump Locally Before Release
2
+
3
+ This guide explains how to test git-jump in local projects before releasing a new version to RubyGems.
4
+
5
+ ## Prerequisites
6
+
7
+ - Ruby >= 3.2.0
8
+ - Bundler installed (`gem install bundler`)
9
+
10
+ ## Method 1: Using `bundle exec rake install`
11
+
12
+ This installs the gem locally on your system:
13
+
14
+ ```bash
15
+ # From the git-jump directory
16
+ cd /path/to/git-jump
17
+
18
+ # Install dependencies
19
+ bundle install
20
+
21
+ # Build and install the gem locally
22
+ bundle exec rake install
23
+ ```
24
+
25
+ After running this, `git-jump` will be available system-wide. You can test it in any project:
26
+
27
+ ```bash
28
+ cd /path/to/your/test-project
29
+ git-jump status
30
+ git-jump list
31
+ ```
32
+
33
+ ## Method 2: Using `gem build` + `gem install`
34
+
35
+ Build the gem manually and install it:
36
+
37
+ ```bash
38
+ # From the git-jump directory
39
+ cd /path/to/git-jump
40
+
41
+ # Build the gem
42
+ gem build git-jump.gemspec
43
+
44
+ # Install the built gem (version will match lib/git_jump/version.rb)
45
+ gem install ./git-jump-*.gem
46
+ ```
47
+
48
+ ## Method 3: Using Bundler's Path Option (Recommended for Development)
49
+
50
+ Add git-jump to a test project's Gemfile using the local path:
51
+
52
+ ```ruby
53
+ # In your test project's Gemfile
54
+ gem "git-jump", path: "/path/to/git-jump"
55
+ ```
56
+
57
+ Then run:
58
+
59
+ ```bash
60
+ cd /path/to/your/test-project
61
+ bundle install
62
+ bundle exec git-jump status
63
+ ```
64
+
65
+ This method is useful because:
66
+ - Changes to the source code are immediately available
67
+ - No need to rebuild/reinstall after each change
68
+ - Isolated to the specific project
69
+
70
+ ## Method 4: Direct Execution from Source
71
+
72
+ Run git-jump directly from the source directory without installing:
73
+
74
+ ```bash
75
+ # From the git-jump directory
76
+ cd /path/to/git-jump
77
+
78
+ # Run using the exe script
79
+ bundle exec exe/git-jump status
80
+
81
+ # Or run in a different directory
82
+ bundle exec exe/git-jump --help
83
+ ```
84
+
85
+ To test in another project directory:
86
+
87
+ ```bash
88
+ cd /path/to/your/test-project
89
+ /path/to/git-jump/bin/git-jump list
90
+ ```
91
+
92
+ ## Running Tests Before Local Testing
93
+
94
+ Always run the test suite before testing locally:
95
+
96
+ ```bash
97
+ # Run all tests
98
+ bundle exec rspec
99
+
100
+ # Run tests with coverage
101
+ bundle exec rspec
102
+
103
+ # Run linter
104
+ bundle exec rubocop
105
+
106
+ # Run both tests and linter
107
+ bundle exec rake
108
+ ```
109
+
110
+ ## Testing Checklist
111
+
112
+ Before releasing, verify these commands work correctly:
113
+
114
+ 1. **Setup**: `git-jump setup` - Creates config file
115
+ 2. **Install hook**: `git-jump install` - Installs post-checkout hook
116
+ 3. **Add branch**: `git-jump add <branch-name>` - Adds branch to tracking
117
+ 4. **List branches**: `git-jump list` - Shows tracked branches
118
+ 5. **Jump**: `git-jump jump` - Switches to next branch
119
+ 6. **Jump by index**: `git-jump jump 2` - Switches to branch at index
120
+ 7. **Clear**: `git-jump clear` - Clears non-kept branches
121
+ 8. **Status**: `git-jump status` - Shows current status
122
+ 9. **Version**: `git-jump version` - Shows version number
123
+
124
+ ## Testing the Post-Checkout Hook
125
+
126
+ After installing the hook with `git-jump install`:
127
+
128
+ ```bash
129
+ # Check the hook exists
130
+ cat .git/hooks/post-checkout
131
+
132
+ # Test by checking out branches
133
+ git checkout -b test-branch-1
134
+ git checkout -b test-branch-2
135
+ git checkout main
136
+
137
+ # Verify branches were tracked
138
+ git-jump list
139
+ ```
140
+
141
+ ## Cleaning Up After Testing
142
+
143
+ To remove the locally installed gem:
144
+
145
+ ```bash
146
+ gem uninstall git-jump
147
+ ```
148
+
149
+ To remove git-jump data:
150
+
151
+ ```bash
152
+ # Remove config
153
+ rm -rf ~/.config/git-jump
154
+
155
+ # Remove database
156
+ rm -rf ~/.local/share/git-jump
157
+
158
+ # Or if using custom XDG paths
159
+ rm -rf $XDG_CONFIG_HOME/git-jump
160
+ rm -rf $XDG_DATA_HOME/git-jump
161
+ ```
162
+
163
+ ## Troubleshooting
164
+
165
+ ### Gem not found after installation
166
+
167
+ Make sure the gem's bin directory is in your PATH:
168
+
169
+ ```bash
170
+ gem environment | grep "EXECUTABLE DIRECTORY"
171
+ ```
172
+
173
+ ### Changes not reflected
174
+
175
+ If using Method 1 or 2, you need to rebuild and reinstall after making changes:
176
+
177
+ ```bash
178
+ bundle exec rake install
179
+ ```
180
+
181
+ ### Database errors
182
+
183
+ Delete the SQLite database and start fresh:
184
+
185
+ ```bash
186
+ rm ~/.local/share/git-jump/branches.db
187
+ ```
@@ -30,7 +30,7 @@ module GitJump
30
30
  #{" "}
31
31
  "$RUBY_PATH" -e "
32
32
  begin
33
- require 'git_jump'
33
+ require 'git_jump/hooks/post_checkout'
34
34
  GitJump::Hooks::PostCheckout.new('$(pwd)').run
35
35
  rescue LoadError
36
36
  # Gem not available, skip silently
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "utils/xdg"
4
+
3
5
  module GitJump
4
6
  # Manages configuration from TOML file
5
7
  class Config
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../repository"
4
+ require_relative "../config"
5
+ require_relative "../database"
6
+
3
7
  module GitJump
4
8
  module Hooks
5
9
  # Post-checkout hook implementation
@@ -5,6 +5,7 @@ require_relative "../version"
5
5
  require_relative "../utils/xdg"
6
6
  require_relative "../utils/output"
7
7
  require_relative "../config"
8
+ require_relative "../database"
8
9
  require_relative "../repository"
9
10
  require_relative "../actions/base"
10
11
  require_relative "../actions/install"
@@ -50,15 +50,16 @@ module GitJump
50
50
  def branch_list(branches, current_branch)
51
51
  return if quiet || branches.empty?
52
52
 
53
- heading("Tracked Branches")
53
+ max_branch_width = calculate_max_branch_width
54
54
 
55
55
  rows = branches.map.with_index(1) do |branch, index|
56
56
  name = branch["name"]
57
57
  marker = name == current_branch ? Colors.green("→") : " "
58
58
  styled_name = name == current_branch ? Colors.green(name, bold: true) : name
59
+ truncated_name = truncate_text(styled_name, max_branch_width)
59
60
  last_visited = format_time(branch["last_visited_at"])
60
61
 
61
- ["#{marker} #{index}", styled_name, last_visited]
62
+ ["#{marker} #{index}", truncated_name, last_visited]
62
63
  end
63
64
 
64
65
  table(["#", "Branch", "Last Visited"], rows)
@@ -93,6 +94,60 @@ module GitJump
93
94
  rescue StandardError
94
95
  "unknown"
95
96
  end
97
+
98
+ # Get terminal width using multiple detection methods
99
+ def terminal_width
100
+ # Try tput command
101
+ width = `tput cols 2>/dev/null`.to_i
102
+ return width if width.positive?
103
+
104
+ # Try COLUMNS environment variable
105
+ width = ENV.fetch("COLUMNS", 0).to_i
106
+ return width if width.positive?
107
+
108
+ # Default fallback
109
+ 80
110
+ end
111
+
112
+ # Calculate maximum width for branch names in the table
113
+ # Table structure: | # | Branch | Last Visited |
114
+ # Fixed widths:
115
+ # - '# ' column: ~5 chars (marker + index)
116
+ # - 'Last Visited' column: ~14 chars
117
+ # - Table borders and padding: ~12 chars
118
+ def calculate_max_branch_width
119
+ fixed_width = 5 + 14 + 12
120
+ branch_width = terminal_width - fixed_width
121
+
122
+ # Ensure minimum branch width for readability
123
+ [branch_width, 20].max
124
+ end
125
+
126
+ # Strip ANSI color codes from text for accurate length calculation
127
+ def strip_ansi_codes(text)
128
+ text.gsub(/\e\[[0-9;]*m/, "")
129
+ end
130
+
131
+ # Truncate text to max_width, preserving ANSI color codes
132
+ def truncate_text(text, max_width)
133
+ plain_text = strip_ansi_codes(text)
134
+ return text if plain_text.length <= max_width
135
+ return "..." if max_width < 3
136
+
137
+ # Check if text contains ANSI color codes
138
+ if text.include?("\e[")
139
+ # Extract all leading ANSI codes (color, bold, etc.)
140
+ color_start = text[/^(\e\[[0-9;]*m)+/, 0] || ""
141
+ color_end = text[/\e\[0m$/] || ""
142
+
143
+ # Truncate the plain text and reapply colors
144
+ truncated = "#{plain_text[0...(max_width - 3)]}..."
145
+ color_start + truncated + color_end
146
+ else
147
+ # No color codes, simple truncation
148
+ "#{plain_text[0...(max_width - 3)]}..."
149
+ end
150
+ end
96
151
  end
97
152
  end
98
153
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitJump
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-jump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Sáenz
@@ -131,12 +131,14 @@ executables:
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
+ - AGENTS.md
134
135
  - CHANGELOG.md
135
136
  - CODE_OF_CONDUCT.md
136
137
  - LICENSE.txt
137
138
  - README.md
138
139
  - Rakefile
139
140
  - db/schema.rb
141
+ - docs/local-testing.md
140
142
  - exe/git-jump
141
143
  - lib/git_jump.rb
142
144
  - lib/git_jump/action.rb
@@ -187,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
189
  - !ruby/object:Gem::Version
188
190
  version: '0'
189
191
  requirements: []
190
- rubygems_version: 3.7.2
192
+ rubygems_version: 4.0.1
191
193
  specification_version: 4
192
194
  summary: Smart git branch tracker and switcher with SQLite persistence
193
195
  test_files: []