git 4.0.6 → 4.0.7

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: 745cd9f7795f87b785c30e602beac5dbb8316285483c09fb2916501abbe3bfc5
4
- data.tar.gz: 55d63b9dbc37818a2cd8318719c574cc6bf3d5ea0ec472bc30b1c20f7aa72469
3
+ metadata.gz: 04704cbd94c551655a2fbb2df1dc9729806ff3cb6fc602c2634175f57b6cbc9e
4
+ data.tar.gz: de882dd34757ce68ca53ec6b2f355da26c56d49086af58f65e9e5631ac73be68
5
5
  SHA512:
6
- metadata.gz: e69ba4cc1d26544190b301efee7ecefc735aa39cf516dd668194a8bb3dbaa2db46ba21556c94ba434c88397615b9cab46141a9fe616bba8948964190ac6163af
7
- data.tar.gz: 9f66300f937ca9bef982a6c149c53c404548fb59d27fa07e3be853f7b783525f65ef03f8e2a184189dc780fd0556716199162ddfadbc007e315a7f5c2988275a
6
+ metadata.gz: bb2886c7799b96c038a6677e7ebb4ce84401be30ca083bb2a7b2a05382a1ed86601aaa9b94f4965924c6e57247a8c4d1b3bb70bbb9d6422a48669a0ebd4a2a76
7
+ data.tar.gz: 70b5390c8439d0b5675729c943c69f53e94e1493f33cfe75df829cddf406221bac3df66d27ffc472ad581d1fa65f59da35a29a5317ecce2395b09d766ee797c5
@@ -0,0 +1,823 @@
1
+ # GitHub Copilot Instructions for ruby-git
2
+
3
+ ## Project Overview
4
+
5
+ ruby-git is a Ruby gem that provides a Ruby interface to Git repositories.
6
+
7
+ The git gem wraps system calls to the `git` command line and provides an API to:
8
+ - Create, read, and manipulate Git repositories
9
+ - Work with branches, commits, tags, and remotes
10
+ - Inspect repository history and objects
11
+ - Perform Git operations like merge, clone, fetch, push, etc.
12
+ - Handle complex interactions including branching, merging, and patch generation
13
+
14
+ **Current Status:** Stable project supporting Ruby 3.2.0+ minimum and Git 2.28.0+.
15
+ Compatible with MRI Ruby 3.2+ on Mac, Linux, and Windows.
16
+
17
+ ## Architecture & Module Organization
18
+
19
+ ruby-git follows a modular architecture:
20
+
21
+ - **Git::Base** - Main interface for repository operations (most major actions)
22
+ - **Git::Lib** - Low-level Git command execution via system calls
23
+ - **Git::CommandLine** - Handles Git command construction and execution with timeout
24
+ support
25
+ - **Git Objects** - Repository objects (Commit, Tree, Blob, Tag) via `Git::Object`
26
+ - **Git::Status** - Working directory status (tracked/untracked/modified files)
27
+ - **Git::Diff** - Diff operations returning file-level patches and statistics
28
+ - **Git::Log** - Enumerable query builder for commit history
29
+ - **Git::Branch/Branches** - Branch management (local and remote)
30
+ - **Git::Remote** - Remote repository references
31
+ - **Git::Worktree/Worktrees** - Git worktree support
32
+ - **Git::Stash/Stashes** - Stash management
33
+
34
+ Key directories:
35
+
36
+ - `lib/git/` - Core library code
37
+ - `tests/units/` - Test::Unit test suite
38
+ - `doc/` - YARD-generated documentation
39
+ - `pkg/` - Built gem packages
40
+ - `redesign/` - Architecture redesign documentation
41
+
42
+ ## Coding Standards
43
+
44
+ ### Ruby Style
45
+
46
+ - Use `frozen_string_literal: true` at the top of all Ruby files
47
+ - Follow Ruby community style guide (Rubocop-compatible)
48
+ - Require Ruby 3.2.0+ features and idioms
49
+ - Use keyword arguments for methods with multiple parameters
50
+ - Prefer `private` over `private :method_name` for method visibility
51
+ - Use pattern matching for complex conditional logic where appropriate
52
+
53
+ ### Code Organization
54
+
55
+ - Keep classes focused and single-responsibility
56
+ - Use modules for mixins and namespace organization
57
+ - Place related classes in the same file only if they're tightly coupled
58
+ - One public class per file as a general rule
59
+ - Core library code organized in `lib/git/` directory
60
+
61
+ ### Naming Conventions
62
+
63
+ - Classes/Modules: PascalCase (e.g., `Git::Base`, `Git::Branch`, `Git::CommandLine`)
64
+ - Methods/variables: snake_case (e.g., `current_branch`, `ls_files`, `commit_all`)
65
+ - Constants: UPPER_SNAKE_CASE (e.g., `VERSION`)
66
+ - Predicate methods: end with `?` (e.g., `bare?`, `success?`, `exist?`)
67
+ - Dangerous methods: end with `!` if they modify in place
68
+ - Instance variables: `@variable_name`
69
+ - Avoid class variables; prefer class instance variables or constants
70
+
71
+ ## Design Philosophy
72
+
73
+ **Note:** As of v2.x, this design philosophy is aspirational. Future versions may
74
+ include interface changes to fully align with these principles.
75
+
76
+ The git gem is designed as a lightweight wrapper around the `git` command-line tool,
77
+ providing a simple and intuitive Ruby interface for programmatically interacting with
78
+ Git.
79
+
80
+ ### Principle of Least Surprise
81
+
82
+ - Do not introduce unnecessary abstraction layers
83
+ - Do not modify Git's core functionality
84
+ - Maintain close alignment with the existing `git` command-line interface
85
+ - Avoid extensions or alterations that could lead to unexpected behaviors
86
+ - Allow users to leverage their existing knowledge of Git
87
+
88
+ ### Direct Mapping to Git Commands
89
+
90
+ - Git commands are implemented within the `Git::Base` class
91
+ - Each method should directly correspond to a `git` command
92
+ - Example: `git add` → `Git::Base#add`, `git ls-files` → `Git::Base#ls_files`
93
+ - When a single Git command serves multiple distinct purposes, use the command name
94
+ as a prefix followed by a descriptive suffix
95
+ - Example: `#ls_files_untracked`, `#ls_files_staged`
96
+ - Introduce aliases to provide more user-friendly method names where appropriate
97
+
98
+ ### Parameter Naming
99
+
100
+ - Parameters are named after their corresponding long command-line options
101
+ - Ensures familiarity for developers already accustomed to Git
102
+ - Note: Not all Git command options are supported
103
+
104
+ ### Output Processing
105
+
106
+ - Translate Git command output into Ruby objects for easier programmatic use
107
+ - Ruby objects often include methods that allow for further Git operations
108
+ - Provide additional functionality while staying true to underlying Git behavior
109
+
110
+ ### Documentation
111
+
112
+ - Use YARD syntax for all public methods
113
+ - Include `@param`, `@return`, `@raise`, `@example` tags
114
+ - Document edge cases, platform differences, and security considerations
115
+ - Keep method documentation up-to-date with implementation
116
+ - Add `@api private` for internal-only methods
117
+ - Document Git version requirements and compatibility
118
+
119
+ Example:
120
+
121
+ ```ruby
122
+ # Opens a Git repository
123
+ #
124
+ # @param [String, Pathname] path The path to the working directory or .git directory
125
+ # @param [Hash] options The options for this command (see list of valid options below)
126
+ # @option options [Logger] :log A logger to use for Git operations
127
+ # @option options [Numeric] :timeout Maximum seconds to wait for Git commands (0 for no timeout)
128
+ # @return [Git::Base] an object that can execute git commands in the context of the repository
129
+ # @raise [ArgumentError] if path is not a valid Git repository
130
+ # @example Open a repository
131
+ # git = Git.open('/path/to/repo')
132
+ # puts git.log.first.message
133
+ # @api public
134
+ def self.open(path, options = {})
135
+ # implementation
136
+ end
137
+ ```
138
+
139
+ ## Key Technical Details
140
+
141
+ ### Git Command Execution
142
+
143
+ All Git commands are executed through the `Git::CommandLine` class which:
144
+ - Constructs Git commands with proper argument escaping
145
+ - Handles environment variables and working directory context
146
+ - Manages command execution with timeout support
147
+ - Captures stdout, stderr, and exit status
148
+ - Raises appropriate errors on command failures
149
+
150
+ ### Major Classes and Their Responsibilities
151
+
152
+ 1. **Git::Base**: The main repository interface
153
+ - Entry point for most Git operations
154
+ - Delegates to `Git::Lib` for low-level operations
155
+ - Manages working directory, index, and repository references
156
+ - Returns domain objects (Branch, Status, Diff, Log, etc.)
157
+
158
+ 2. **Git::Lib**: Low-level command execution
159
+ - Executes Git commands via `Git::CommandLine`
160
+ - Parses Git command output
161
+ - Minimal business logic - focuses on command execution
162
+
163
+ 3. **Git::CommandLine**: Command execution layer
164
+ - Builds Git command arrays with proper escaping
165
+ - Manages subprocess execution with timeout support
166
+ - Handles timeout and error conditions
167
+ - Returns `Git::CommandLineResult` with output and status
168
+
169
+ 4. **Git Objects** (Commit, Tree, Blob, Tag)
170
+ - Immutable representations of Git objects
171
+ - Lazy-loaded from repository
172
+ - Methods for inspecting object properties and relationships
173
+
174
+ 5. **Git::Status**: Working directory status
175
+ - Enumerable collection of `Git::Status::StatusFile`
176
+ - Tracks added, changed, deleted, and untracked files
177
+ - Similar to `git status` command output
178
+
179
+ 6. **Git::Diff**: Diff operations
180
+ - Enumerable collection of `Git::Diff::DiffFile`
181
+ - Per-file patches and statistics
182
+ - Total insertion/deletion statistics
183
+
184
+ 7. **Git::Log**: Commit history query builder
185
+ - Chainable methods for building log queries
186
+ - Enumerable returning `Git::Object::Commit` objects
187
+ - Supports filtering by path, date range, author, etc.
188
+
189
+ ### Path Handling
190
+
191
+ ruby-git handles three types of paths:
192
+ - **Working directory paths**: Relative to repository working directory
193
+ - **Git directory paths**: The `.git` directory location
194
+ - **Object paths**: Paths within Git tree objects
195
+
196
+ The gem provides `Git::Path` and `Git::EscapedPath` for handling paths with special
197
+ characters.
198
+
199
+ ### Error Handling
200
+
201
+ The gem raises errors that inherit from `Git::Error`:
202
+ - `Git::FailedError`: Git command exited with non-zero status
203
+ - `Git::SignaledError`: Git command was killed by a signal
204
+ - `Git::TimeoutError`: Git command exceeded timeout (subclass of SignaledError)
205
+ - `ArgumentError`: Invalid arguments passed to methods
206
+
207
+ All Git command errors include the command, output, and status for debugging.
208
+
209
+ ## Development Methodology
210
+
211
+ ### Test Driven Development (TDD)
212
+
213
+ **This project strictly follows TDD practices. All code MUST be written using the
214
+ Red-Green-Refactor cycle.**
215
+
216
+ You are an expert software engineer following a strict Test-Driven Development (TDD)
217
+ workflow.
218
+
219
+ **Core TDD Principles**
220
+
221
+ - **Never write production code without a failing test first.**
222
+ - **Bug Fixes Start with Tests:** Before fixing any bug, write a failing test that
223
+ demonstrates the bug and fails in the expected way. Only then fix the code to make
224
+ the test pass.
225
+ - **Tests Drive Design:** Let the test dictate the API and architecture. If the test
226
+ is hard to write, the design is likely wrong. When this happens, stop and suggest
227
+ one or more design alternatives. Offer to stash any current changes and work on the
228
+ design improvements first before continuing with the original task.
229
+ - **Write Tests Incrementally:** Focus on small, atomic tests that verify exactly one
230
+ logical behavior.
231
+ - **No Implementation in Advance:** Only write the code strictly needed to pass the
232
+ current test.
233
+
234
+ **Phase 1: Analysis & Planning** Before writing any code:
235
+
236
+ 1. Analyze the request.
237
+ 2. Create a checklist of small, isolated implementation steps.
238
+
239
+ **Phase 2: The RED-GREEN-REFACTOR Cycle** Execute the checklist items one by one.
240
+ Build each checklist item using multiple RED-GREEN iterations if needed. Follow with
241
+ a REFACTOR step before moving to the next checklist item.
242
+
243
+ You must complete the _entire_ cycle for a checklist item before moving to the next.
244
+
245
+ **Completion Criteria for a Checklist Item:**
246
+ - All functionality for that item is implemented
247
+ - All related tests pass
248
+ - Code is clean and well-factored
249
+ - Ready to move to the next independent item
250
+
251
+ 1. **RED (The Failing Test):**
252
+
253
+ - Write a single, focused, failing test or extend an existing test for the current
254
+ checklist item
255
+ - Only write enough of a test to get an expected, failing result (the test should
256
+ fail for the *right* reason)
257
+ - **Execute** the test using the terminal command `bundle exec ruby -I lib:tests
258
+ tests/units/test_name.rb` or `bin/test test_name` and **analyze** the output.
259
+ - Confirm it fails with an _expected_ error (e.g., assertion failure or missing
260
+ definition).
261
+ - **Validation:** If the test passes without implementation, the test is invalid
262
+ or the logic already exists—revise or skip.
263
+
264
+ 2. **GREEN (Make it Pass):**
265
+
266
+ - Write the _minimum amount of code_ required to make the test pass.
267
+ - It is acceptable to use hardcoded values or "quick and dirty" logic here just to
268
+ get to green, even if this means intentionally writing clearly suboptimal code
269
+ that you will improve during the REFACTOR step.
270
+ - **Execute** the test again using the terminal command `bundle exec ruby -I
271
+ lib:tests tests/units/test_name.rb` or `bin/test test_name` and **verify** it
272
+ passes.
273
+ - _Constraint:_ Do not implement future features or optimizations yet.
274
+
275
+ 3. **REFACTOR (Make it Right):**
276
+
277
+ - **Critical Step:** You must consider refactoring _before_ starting the next
278
+ checklist item.
279
+ - Remove duplication, improve variable names, and apply design patterns.
280
+ - Skip this step only if the code is already clean and simple—avoid
281
+ over-engineering.
282
+ - **Execute** all tests using the terminal command `bundle exec rake` and
283
+ **verify** they still pass.
284
+ - **Test Independence:** Verify tests can run independently in any order.
285
+
286
+ **Additional Guidelines**
287
+
288
+ These supplement the RED-GREEN-REFACTOR cycle:
289
+
290
+ - If the implementation reveals a complex logic gap, add it to your checklist, but
291
+ finish the current cycle first.
292
+ - Do not generate a "wall of text." Keep code blocks small and focused on the current
293
+ step.
294
+ - Stop and ask for clarification if a step is ambiguous.
295
+
296
+ #### Example TDD Session
297
+
298
+ ```ruby
299
+ # Step 1: Write first failing test
300
+ require_relative '../test_helper'
301
+
302
+ class TestGitBranch < Test::Unit::TestCase
303
+ def setup
304
+ @repo = clone_working_repo
305
+ @git = Git.open(@repo)
306
+ end
307
+
308
+ def test_creates_new_branch
309
+ @git.branch('feature').create
310
+ assert @git.branches.local.map(&:name).include?('feature')
311
+ end
312
+ end
313
+
314
+ # Run test → RED (method doesn't exist or doesn't work)
315
+
316
+ # Step 2: Minimal code to pass
317
+ class Git::Branch
318
+ def create
319
+ @base.lib.branch_new(@name)
320
+ end
321
+ end
322
+
323
+ # Run test → GREEN
324
+
325
+ # Step 3: Write next failing test
326
+ def test_checks_out_new_branch
327
+ branch = @git.branch('feature').create
328
+ @git.checkout(branch)
329
+ assert_equal 'feature', @git.current_branch
330
+ end
331
+
332
+ # Run test → RED (checkout doesn't work correctly)
333
+
334
+ # Step 4: Implement actual functionality
335
+ def checkout
336
+ @base.lib.checkout(@name)
337
+ @base.lib.branch_current
338
+ end
339
+
340
+ # Run test → GREEN
341
+
342
+ # Step 5: REFACTOR - Improve code organization
343
+ def checkout
344
+ @base.checkout(@name)
345
+ end
346
+
347
+ # Run all tests → Still GREEN
348
+ # Checklist item complete, move to next item...
349
+ ```
350
+
351
+ ## Testing Requirements
352
+
353
+ ### Test Framework
354
+
355
+ - Use **Test::Unit** for all tests
356
+ - Tests located in `tests/units/` directory
357
+ - Test files named `test_*.rb`
358
+ - Main test helper: `tests/test_helper.rb` provides utility methods
359
+ - Uses Mocha for mocking
360
+
361
+ ### Coverage Target
362
+
363
+ Maintain **high code coverage** through TDD practice.
364
+
365
+ ### Test Organization
366
+
367
+ ```ruby
368
+ require_relative '../test_helper'
369
+
370
+ class TestGitOpen < Test::Unit::TestCase
371
+ def setup
372
+ @repo = clone_working_repo
373
+ end
374
+
375
+ def test_opens_existing_repository
376
+ git = Git.open(@repo)
377
+ assert_kind_of Git::Base, git
378
+ end
379
+
380
+ def test_raises_on_invalid_path
381
+ assert_raises(ArgumentError) do
382
+ Git.open('/nonexistent/path')
383
+ end
384
+ end
385
+ end
386
+ ```
387
+
388
+ ### Critical Test Cases
389
+
390
+ - Repository operations (open, init, clone)
391
+ - Branch operations (create, checkout, delete, merge)
392
+ - Commit operations (add, commit, reset)
393
+ - Remote operations (fetch, pull, push)
394
+ - Status and diff operations
395
+ - Log queries with various filters
396
+ - Timeout handling for long-running operations
397
+ - Error conditions (invalid repos, failed commands, timeouts)
398
+ - Cross-platform compatibility (Mac, Linux, Windows)
399
+ - Path handling with special characters and Unicode
400
+ - Encoding issues with different character sets
401
+ - Git version compatibility (minimum 2.28.0)
402
+
403
+ ### Test Helpers
404
+
405
+ The `Test::Unit::TestCase` base class provides:
406
+ - `clone_working_repo`: Creates a temporary clone of test repository
407
+ - `create_temp_repo`: Creates a temporary repository for testing
408
+ - `with_temp_dir`: Provides a temporary directory for tests
409
+ - `git_teardown`: Automatically cleans up temporary files
410
+ - Test fixtures in `tests/files/`
411
+
412
+ ## Running Tests
413
+
414
+ ```bash
415
+ # Run all tests
416
+ bundle exec rake test
417
+
418
+ # Run specific test file
419
+ bundle exec ruby -I lib:tests tests/units/test_base.rb
420
+
421
+ # Run specific test by name
422
+ bundle exec ruby -I lib:tests tests/units/test_base.rb -n test_opens_existing_repository
423
+
424
+ # Run tests in Docker (tests against multiple Ruby versions)
425
+ bin/test-in-docker
426
+
427
+ # View coverage report
428
+ open coverage/index.html
429
+ ```
430
+
431
+ ## Ruby and Git Version Compatibility
432
+
433
+ ### Current Support
434
+
435
+ - Minimum Ruby: 3.2.0
436
+ - Minimum Git: 2.28.0 or greater
437
+ - Actively tested on: MRI Ruby 3.2, 3.4, and 4.0
438
+ - Platforms: Mac, Linux, Windows
439
+ - CI tests on multiple Ruby versions and platforms
440
+
441
+ ### Dependencies
442
+
443
+ - `activesupport` (>= 5.0) - For utilities and deprecation handling
444
+ - `addressable` (~> 2.8) - For URI parsing
445
+ - `process_executer` (~> 4.0) - For subprocess execution with timeout
446
+ - `rchardet` (~> 1.9) - For character encoding detection
447
+
448
+ ### Platform Considerations
449
+
450
+ **Cross-Platform Compatibility:**
451
+ - Git command execution works on all platforms
452
+ - Handle Windows path separators and drive letters appropriately
453
+ - Test Git operations on all platforms
454
+ - Be aware of platform-specific Git behavior (e.g., line endings, permissions)
455
+ - Windows has different path handling and file system behavior
456
+
457
+ **Git Version Compatibility:**
458
+ - Minimum Git version is 2.28.0
459
+ - Test with different Git versions when using newer features
460
+ - Gracefully handle missing Git features on older versions
461
+ - Document Git version requirements for specific features
462
+
463
+ **Encoding Handling:**
464
+ - Handle different default encodings across platforms
465
+ - Use `rchardet` for automatic encoding detection
466
+ - Test with UTF-8 and other encodings
467
+ - Binary vs. text mode differences on Windows
468
+
469
+ ## Configuration & Settings
470
+
471
+ ### Gemspec Configuration
472
+
473
+ Located in `git.gemspec`:
474
+
475
+ - Runtime dependencies: activesupport, addressable, process_executer, rchardet
476
+ - Development dependencies: test-unit, mocha, rake, rubocop, yard, etc.
477
+ - `required_ruby_version >= 3.2.0`
478
+ - Git requirement: `git 2.28.0 or greater`
479
+
480
+ ### Rake Configuration
481
+
482
+ Located in `Rakefile`:
483
+
484
+ - Default task runs Test::Unit tests
485
+ - Rubocop for linting
486
+ - YARD for documentation generation
487
+ - Tasks defined in `tasks/` directory
488
+
489
+ ## Error Handling
490
+
491
+ - Raise specific exception classes from `Git::Error` hierarchy
492
+ - Always include relevant context (command, status, output) in exceptions
493
+ - Provide helpful error messages that guide users to solutions
494
+ - Handle platform-specific errors gracefully
495
+ - Document all error conditions in method YARD docs
496
+ - Never swallow exceptions silently
497
+ - Use `ArgumentError` for invalid method arguments
498
+
499
+ **Error Design Principles:**
500
+ - Inherit from `Git::Error` for all gem-specific errors
501
+ - `Git::FailedError`: Command failed (non-zero exit)
502
+ - `Git::SignaledError`: Command killed by signal
503
+ - `Git::TimeoutError`: Command exceeded timeout (subclass of SignaledError)
504
+ - Include structured data (command, output, status) for debugging
505
+ - Make errors programmatically inspectable
506
+ - Distinguish between user errors and runtime errors
507
+
508
+ ## Performance Considerations
509
+
510
+ ### Git Command Execution
511
+
512
+ - Commands execute with configurable timeout (global or per-command)
513
+ - Clean up resources properly
514
+ - Handle large repository operations efficiently
515
+ - Subprocess execution is handled internally by `Git::CommandLine`
516
+
517
+ ### Memory Management
518
+
519
+ - Lazy-load Git objects when possible
520
+ - Stream large outputs rather than buffering everything
521
+ - Be mindful of memory usage with large diffs and logs
522
+ - Clean up temporary files and resources
523
+
524
+ ### Repository Operations
525
+
526
+ - Minimize Git command executions
527
+ - Cache Git objects when appropriate
528
+ - Use batch operations where possible
529
+ - Consider performance implications of deep history traversal
530
+
531
+ ## Documentation
532
+
533
+ - Keep CHANGELOG.md updated with all user-facing changes
534
+ - Update README.md examples when API changes
535
+ - Document breaking changes prominently in CHANGELOG
536
+ - Use inline YARD comments for comprehensive API documentation
537
+ - Generate docs with `bundle exec yard doc`
538
+ - Ensure examples in documentation actually work
539
+ - Document platform-specific behavior
540
+ - Document Git version requirements for features
541
+ - Include security considerations (e.g., shell injection risks with certain
542
+ operations)
543
+
544
+ ## Key Documents
545
+
546
+ Always consult these before implementing features:
547
+
548
+ - **README.md** - Project overview, usage examples, and getting started
549
+ - **CHANGELOG.md** - Version history, breaking changes, and migration guides
550
+ - **LICENSE** - MIT License
551
+ - **CONTRIBUTING.md** - Contribution guidelines
552
+ - **MAINTAINERS.md** - Maintainer information
553
+ - **redesign/** - Architecture redesign documentation
554
+ - Full YARD documentation at https://rubydoc.info/gems/git/
555
+
556
+ ## Code Quality Checklist
557
+
558
+ Before committing, ensure:
559
+
560
+ **Testing:**
561
+ - [ ] **TDD process followed** - Tests written before implementation
562
+ - [ ] All tests pass (`bundle exec rake test`)
563
+ - [ ] No Ruby warnings when running tests
564
+
565
+ **Code Style:**
566
+ - [ ] Code follows Ruby style conventions (Rubocop)
567
+ - [ ] YARD documentation for public methods
568
+
569
+ **Compatibility:**
570
+ - [ ] Backward compatibility maintained (unless breaking change)
571
+ - [ ] Cross-platform compatibility considered (Windows, macOS, Linux)
572
+ - [ ] Git version compatibility (minimum 2.28.0)
573
+
574
+ **Documentation & Safety:**
575
+ - [ ] CHANGELOG.md updated for user-facing changes
576
+ - [ ] Security considerations addressed (command injection, etc.)
577
+ - [ ] Resource cleanup (file handles, temporary files)
578
+
579
+ ## Git Commit Conventions
580
+
581
+ **CRITICAL:** All commits **MUST** adhere to the [Conventional Commits
582
+ standard](https://www.conventionalcommits.org/en/v1.0.0/). Commits not adhering to
583
+ this standard will cause the CI build to fail. PRs will not be merged if they include
584
+ non-conventional commits.
585
+
586
+ ### Conventional Commit Format
587
+
588
+ The simplest format: `type: description`
589
+
590
+ **Valid types** (see [.commitlintrc.yml](../.commitlintrc.yml) for full list):
591
+ - `feat:` - New user facing functionality
592
+ - `fix:` - Bug fixes
593
+ - `docs:` - Documentation only
594
+ - `test:` - Adding/updating tests
595
+ - `refactor:` - Code restructuring without changing behavior
596
+ - `chore:` - Chores and maintenance (e.g., tooling, dependency bumps)
597
+ - `perf:` - Performance improvements
598
+ - `build:` - Build system or external dependency changes
599
+ - `ci:` - Continuous integration configuration and scripts
600
+ - `style:` - Code style and formatting only (no functional changes)
601
+ - `revert:` - Revert a previous commit
602
+
603
+ **Description rules:**
604
+ 1. Must NOT start with an upper case letter
605
+ 2. Must be no more than 100 characters
606
+ 3. Must NOT end with punctuation
607
+
608
+ **Examples:**
609
+ - `feat: add the --merges option to Git::Lib.log`
610
+ - `fix: exception thrown by Git::Lib.log when repo has no commits`
611
+ - `docs: add conventional commit announcement to README.md`
612
+
613
+ **Breaking changes** must include an exclamation mark before the colon:
614
+ - `feat!: removed Git::Base.commit_force`
615
+
616
+ **Full format:**
617
+ ```
618
+ type[optional scope][!]: description
619
+
620
+ [optional body]
621
+
622
+ [optional footer(s)]
623
+ ```
624
+
625
+ **Version incrementing:**
626
+ - Breaking change → **major** version increment
627
+ - New feature → **minor** version increment
628
+ - Neither → **patch** version increment
629
+
630
+ **Pre-commit hook:** Run `bin/setup` in the project root to install a git pre-commit
631
+ hook that validates conventional commit messages before pushing to GitHub.
632
+
633
+ This project uses [release-please](https://github.com/googleapis/release-please) for
634
+ automated releases based on conventional commits.
635
+
636
+ ## Pull Request Guidelines
637
+
638
+ **Branch Strategy:**
639
+
640
+ 1. Ensure local main is up-to-date: `git fetch origin main`
641
+ 2. Create a new branch from origin/main: `git checkout -b feature/your-feature
642
+ origin/main`
643
+ 3. Make your changes following TDD
644
+ 4. Ensure all tests pass and code quality checks pass
645
+ 5. Push the branch and create a PR
646
+
647
+ **PR Description Should Include:**
648
+
649
+ - What problem does this solve?
650
+ - What approach was taken?
651
+ - Any breaking changes?
652
+ - Testing performed (manual and automated)
653
+ - Platform-specific considerations
654
+ - Related issues/PRs
655
+
656
+ **Review Checklist:**
657
+
658
+ - All commits follow Conventional Commits standard (CI will fail otherwise)
659
+ - Tests demonstrate the change works
660
+ - All tests pass (`bundle exec rake default`)
661
+ - Documentation updated (YARD comments for public methods)
662
+ - CHANGELOG.md will be automatically updated by release-please
663
+ - No breaking changes without major version bump or exclamation mark in commit
664
+ - At least one approval from a project maintainer required before merge
665
+
666
+ ## Special Considerations
667
+
668
+ ### Security
669
+
670
+ - **Command Injection**: When using single-string commands, be aware of shell
671
+ injection risks
672
+ - **Input Validation**: Validate and sanitize user input before passing to commands
673
+ - **File Permissions**: Be careful with file descriptors and permissions
674
+ - **Resource Limits**: Consider timeout and resource consumption
675
+ - Document security implications in YARD comments
676
+
677
+ ## Current Priorities
678
+
679
+ Based on project status and maintenance needs:
680
+
681
+ ### Stability and Compatibility
682
+
683
+ 1. Maintain Ruby 3.2+ compatibility
684
+ 2. Keep cross-platform support (Mac, Linux, Windows)
685
+ 3. Support Git 2.28.0+ versions
686
+ 4. Ensure backward compatibility within major versions
687
+
688
+ ### Code Quality
689
+
690
+ 1. Maintain high test coverage
691
+ 2. Follow TDD strictly for all changes
692
+ 3. Keep Rubocop violations at zero
693
+ 4. Comprehensive YARD documentation
694
+
695
+ ### Feature Enhancements
696
+
697
+ Consider these only after TDD test is written:
698
+ - Improved worktree support
699
+ - Enhanced Git LFS integration
700
+ - Better handling of large repositories
701
+ - Performance optimizations for common operations
702
+ - Additional Git operations as needed
703
+
704
+ ### Documentation
705
+
706
+ - Keep README.md examples current and comprehensive
707
+ - Add more real-world examples
708
+ - Document common pitfalls and gotchas
709
+ - Platform-specific behavior documentation
710
+ - Complete architecture redesign documentation in `redesign/`
711
+
712
+ ## Useful Commands
713
+
714
+ ```bash
715
+ # Install dependencies and setup pre-commit hooks
716
+ bin/setup
717
+
718
+ # Or just install dependencies
719
+ bundle install
720
+
721
+ # Run full test suite
722
+ bundle exec rake test
723
+
724
+ # Run specific test file using bin/test (preferred method)
725
+ bin/test test_base
726
+
727
+ # Run multiple test files
728
+ bin/test test_object test_archive
729
+
730
+ # Run all unit tests using bin/test
731
+ bin/test
732
+
733
+ # Run tests with a different Git version
734
+ GIT_PATH=/path/to/git/bin-wrappers bin/test
735
+
736
+ # Alternative: run specific test file directly
737
+ bundle exec ruby -I lib:tests tests/units/test_base.rb
738
+
739
+ # Run specific test by name
740
+ bundle exec ruby -I lib:tests tests/units/test_base.rb -n test_opens_existing_repository
741
+
742
+ # Run tests in Docker
743
+ bin/test-in-docker
744
+
745
+ # Generate YARD documentation
746
+ bundle exec yard doc
747
+
748
+ # Start documentation server
749
+ bundle exec yard server --reload
750
+
751
+ # Build gem
752
+ bundle exec rake build
753
+
754
+ # Check code style
755
+ bundle exec rubocop
756
+
757
+ # Auto-fix code style issues
758
+ bundle exec rubocop -a
759
+
760
+ # View coverage report (if configured)
761
+ open coverage/index.html
762
+ ```
763
+
764
+ ## Getting Help
765
+
766
+ - Review README.md for usage examples and architecture
767
+ - Check CHANGELOG.md for version history and breaking changes
768
+ - Read inline YARD documentation in source code
769
+ - Browse full API docs at https://rubydoc.info/gems/git/
770
+ - Look at existing tests for testing patterns
771
+ - Check CI configuration in `.github/workflows/` for supported platforms
772
+ - Review architecture redesign docs in `redesign/` directory
773
+
774
+ ## Important Implementation Notes
775
+
776
+ ### When Working with Git Commands
777
+
778
+ - Always use `Git::CommandLine` for command execution
779
+ - Handle command output encoding properly
780
+ - Consider timeout implications for long-running operations
781
+ - Test with various Git versions (minimum 2.28.0)
782
+ - Properly escape arguments and paths
783
+ - Handle Git error messages and exit codes
784
+
785
+ ### When Working with Paths
786
+
787
+ - Use `Git::Path` for path handling
788
+ - Use `Git::EscapedPath` for paths with special characters
789
+ - Handle Windows path separators appropriately
790
+ - Test with Unicode filenames
791
+ - Consider relative vs. absolute paths
792
+
793
+ ### When Working with Repository Objects
794
+
795
+ - Lazy-load objects when possible
796
+ - Cache objects appropriately
797
+ - Handle missing or invalid objects gracefully
798
+ - Test with various object types (commits, trees, blobs, tags)
799
+ - Consider performance with large repositories
800
+
801
+ ### When Working with Encoding
802
+
803
+ - Use `rchardet` for encoding detection
804
+ - Handle different platform encodings
805
+ - Test with UTF-8, ASCII, and other encodings
806
+ - Be aware of Git's encoding configuration
807
+ - Handle binary files appropriately
808
+
809
+ ### When Working with Timeouts
810
+
811
+ - Use global timeout configuration or per-command overrides
812
+ - Handle `Git::TimeoutError` appropriately
813
+ - Test timeout behavior with long-running operations
814
+ - Document timeout implications in YARD comments
815
+ - Timeout support is built into the command execution layer
816
+
817
+ ### Security Considerations
818
+
819
+ - Be careful with user-supplied paths and arguments
820
+ - Validate and sanitize inputs
821
+ - Use proper argument escaping via `Git::CommandLine`
822
+ - Document security implications
823
+ - Consider Git hook execution risks
@@ -22,7 +22,7 @@ jobs:
22
22
  fail-fast: false
23
23
  matrix:
24
24
  # Only the latest versions of JRuby and TruffleRuby are tested
25
- ruby: ["3.2", "3.3", "3.4", "truffleruby-24.2.1", "jruby-10.0.0.1"]
25
+ ruby: ["3.2", "3.4", "4.0", "truffleruby-24.2.1", "jruby-10.0.0.1"]
26
26
  operating-system: [ubuntu-latest]
27
27
  experimental: [No]
28
28
  java_version: [""]
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "4.0.6"
2
+ ".": "4.0.7"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## [4.0.7](https://github.com/ruby-git/ruby-git/compare/v4.0.6...v4.0.7) (2025-12-29)
9
+
10
+
11
+ ### Other Changes
12
+
13
+ * Add GitHub Copilot instructions ([edf10ec](https://github.com/ruby-git/ruby-git/commit/edf10ec83e0f54153629e32a53fe38856b779aa0))
14
+ * Add redesign index page ([3fdf9e2](https://github.com/ruby-git/ruby-git/commit/3fdf9e2cc2e03f0c3ce26bd17c878c3443fb1323))
15
+ * Add Ruby 4.0 to continuous integration test matrix ([be3cb89](https://github.com/ruby-git/ruby-git/commit/be3cb894f8c346eb8ed0128bbc32b84f90f8b0e3))
16
+ * Address PR review feedback ([c82a3b4](https://github.com/ruby-git/ruby-git/commit/c82a3b41ecd0a7c779726abe30582148ba9e81eb))
17
+
8
18
  ## [4.0.6](https://github.com/ruby-git/ruby-git/compare/v4.0.5...v4.0.6) (2025-11-11)
9
19
 
10
20
 
data/git.gemspec CHANGED
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency 'test-unit', '~> 3.6'
45
45
 
46
46
  unless RUBY_PLATFORM == 'java'
47
+ spec.add_development_dependency 'irb', '~> 1.6'
47
48
  spec.add_development_dependency 'redcarpet', '~> 3.6'
48
49
  spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
49
50
  spec.add_development_dependency 'yardstick', '~> 0.9'
data/lib/git/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  module Git
4
4
  # The current gem version
5
5
  # @return [String] the current gem version.
6
- VERSION = '4.0.6'
6
+ VERSION = '4.0.7'
7
7
  end
data/redesign/index.md ADDED
@@ -0,0 +1,34 @@
1
+ # Architectural Redesign Project
2
+
3
+ [This project was announced in the project's README](../README.md#2025-07-09-architectural-redesign)
4
+
5
+ The git gem is undergoing a significant architectural redesign for the upcoming
6
+ v5.0.0 release. The current architecture has several design challenges that make it
7
+ difficult to maintain and evolve. This redesign aims to address these issues by
8
+ introducing a clearer, more robust, and more testable structure.
9
+
10
+ We have prepared detailed documents outlining the analysis of the current
11
+ architecture and the proposed changes. We encourage our community and contributors to
12
+ review them:
13
+
14
+ 1. [Analysis of the Current Architecture](1_architecture_existing.md): A
15
+ breakdown of the existing design and its challenges.
16
+ 2. [The Proposed Redesign](2_architecture_redesign.md): An overview of the
17
+ new three-layered architecture.
18
+ 3. [Implementation Plan](3_architecture_implementation.md): The step-by-step
19
+ plan for implementing the redesign.
20
+
21
+ Your feedback is welcome! Please feel free to open an issue to discuss the proposed
22
+ changes.
23
+
24
+ > **DON'T PANIC!**
25
+ >
26
+ > While this is a major internal refactoring, our goal is to keep the primary public
27
+ API on the main repository object as stable as possible. Most users who rely on
28
+ documented methods like `g.commit`, `g.add`, and `g.status` should find the
29
+ transition to v5.0.0 straightforward.
30
+ >
31
+ > The breaking changes will primarily affect users who have been relying on the
32
+ internal g.lib accessor, which will be removed as part of this cleanup. For more
33
+ details, please see the "Impact on Users" section in [the redesign
34
+ > document](2_architecture_redesign.md).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.6
4
+ version: 4.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
@@ -163,6 +163,20 @@ dependencies:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
165
  version: '3.6'
166
+ - !ruby/object:Gem::Dependency
167
+ name: irb
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '1.6'
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '1.6'
166
180
  - !ruby/object:Gem::Dependency
167
181
  name: redcarpet
168
182
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +237,7 @@ extensions: []
223
237
  extra_rdoc_files: []
224
238
  files:
225
239
  - ".commitlintrc.yml"
240
+ - ".github/copilot-instructions.md"
226
241
  - ".github/issue_template.md"
227
242
  - ".github/pull_request_template.md"
228
243
  - ".github/workflows/continuous_integration.yml"
@@ -277,6 +292,7 @@ files:
277
292
  - redesign/1_architecture_existing.md
278
293
  - redesign/2_architecture_redesign.md
279
294
  - redesign/3_architecture_implementation.md
295
+ - redesign/index.md
280
296
  - release-please-config.json
281
297
  - tasks/gem_tasks.rake
282
298
  - tasks/rubocop.rake
@@ -289,8 +305,8 @@ licenses:
289
305
  metadata:
290
306
  homepage_uri: http://github.com/ruby-git/ruby-git
291
307
  source_code_uri: http://github.com/ruby-git/ruby-git
292
- changelog_uri: https://rubydoc.info/gems/git/4.0.6/file/CHANGELOG.md
293
- documentation_uri: https://rubydoc.info/gems/git/4.0.6
308
+ changelog_uri: https://rubydoc.info/gems/git/4.0.7/file/CHANGELOG.md
309
+ documentation_uri: https://rubydoc.info/gems/git/4.0.7
294
310
  rubygems_mfa_required: 'true'
295
311
  rdoc_options: []
296
312
  require_paths:
@@ -307,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
323
  version: '0'
308
324
  requirements:
309
325
  - git 2.28.0 or greater
310
- rubygems_version: 3.6.9
326
+ rubygems_version: 4.0.3
311
327
  specification_version: 4
312
328
  summary: An API to create, read, and manipulate Git repositories
313
329
  test_files: []