git 5.0.0.beta.2 → 5.0.0.beta.4
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 +4 -4
- data/.dockerignore +27 -0
- data/.github/copilot-instructions.md +3 -8
- data/.github/hooks/bin-setup-on-worktree.json +11 -0
- data/.github/hooks/run-bin-setup-once.sh +14 -0
- data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
- data/.github/skills/command-implementation/REFERENCE.md +34 -33
- data/.github/skills/command-implementation/SKILL.md +5 -4
- data/.github/skills/command-test-conventions/SKILL.md +13 -9
- data/.github/skills/command-yard-documentation/SKILL.md +14 -6
- data/.github/skills/development-workflow/SKILL.md +20 -14
- data/.github/skills/facade-implementation/REFERENCE.md +19 -22
- data/.github/skills/facade-implementation/SKILL.md +0 -5
- data/.github/skills/facade-test-conventions/SKILL.md +4 -7
- data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
- data/.github/skills/make-skill-template/SKILL.md +53 -3
- data/.github/skills/pr-readiness-review/SKILL.md +22 -2
- data/.github/skills/project-context/SKILL.md +16 -23
- data/.github/skills/pull-request-review/SKILL.md +2 -2
- data/.github/skills/rebase/SKILL.md +148 -0
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
- data/.github/skills/resolve-feedback/SKILL.md +288 -0
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
- data/.github/skills/reviewing-skills/SKILL.md +28 -3
- data/.github/skills/test-debugging/SKILL.md +20 -19
- data/.github/skills/yard-documentation/SKILL.md +671 -483
- data/.github/skills/yard-documentation/element-rules.md +162 -0
- data/.github/skills-deprecated/README.md +21 -0
- data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
- data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
- data/.github/workflows/continuous_integration.yml +3 -2
- data/.rubocop.yml +7 -39
- data/.yard-lint.yml +75 -0
- data/CONTRIBUTING.md +186 -174
- data/Gemfile +17 -0
- data/README.md +86 -23
- data/Rakefile +3 -21
- data/UPGRADING.md +219 -70
- data/docker/test/Dockerfile +32 -0
- data/docker/test/docker-compose.yml +0 -0
- data/git.gemspec +3 -4
- data/lib/git/author.rb +20 -1
- data/lib/git/branch.rb +26 -6
- data/lib/git/branch_delete_failure.rb +3 -0
- data/lib/git/branch_delete_result.rb +6 -3
- data/lib/git/branch_info.rb +6 -6
- data/lib/git/command_line/base.rb +6 -13
- data/lib/git/command_line/capturing.rb +67 -10
- data/lib/git/command_line/result.rb +0 -8
- data/lib/git/command_line/streaming.rb +45 -5
- data/lib/git/command_line.rb +4 -3
- data/lib/git/commands/add.rb +61 -53
- data/lib/git/commands/am/abort.rb +2 -2
- data/lib/git/commands/am/apply.rb +109 -98
- data/lib/git/commands/am/continue.rb +2 -2
- data/lib/git/commands/am/quit.rb +2 -2
- data/lib/git/commands/am/retry.rb +4 -2
- data/lib/git/commands/am/show_current_patch.rb +1 -1
- data/lib/git/commands/am/skip.rb +2 -2
- data/lib/git/commands/am.rb +2 -2
- data/lib/git/commands/apply.rb +7 -2
- data/lib/git/commands/archive/list_formats.rb +3 -3
- data/lib/git/commands/archive.rb +7 -2
- data/lib/git/commands/arguments.rb +1370 -359
- data/lib/git/commands/base.rb +111 -13
- data/lib/git/commands/branch/copy.rb +29 -21
- data/lib/git/commands/branch/create.rb +72 -68
- data/lib/git/commands/branch/delete.rb +25 -17
- data/lib/git/commands/branch/list.rb +76 -60
- data/lib/git/commands/branch/move.rb +29 -21
- data/lib/git/commands/branch/set_upstream.rb +8 -8
- data/lib/git/commands/branch/show_current.rb +3 -3
- data/lib/git/commands/branch/unset_upstream.rb +4 -8
- data/lib/git/commands/branch.rb +2 -2
- data/lib/git/commands/cat_file/batch.rb +36 -20
- data/lib/git/commands/cat_file/filtered.rb +12 -12
- data/lib/git/commands/cat_file/raw.rb +13 -13
- data/lib/git/commands/cat_file.rb +4 -4
- data/lib/git/commands/checkout/branch.rb +7 -5
- data/lib/git/commands/checkout/files.rb +5 -4
- data/lib/git/commands/checkout.rb +4 -4
- data/lib/git/commands/checkout_index.rb +5 -4
- data/lib/git/commands/clean.rb +6 -4
- data/lib/git/commands/clone.rb +5 -4
- data/lib/git/commands/commit.rb +5 -4
- data/lib/git/commands/commit_tree.rb +5 -4
- data/lib/git/commands/config_option_syntax/add.rb +7 -4
- data/lib/git/commands/config_option_syntax/get.rb +9 -5
- data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
- data/lib/git/commands/config_option_syntax/list.rb +8 -4
- data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
- data/lib/git/commands/config_option_syntax/set.rb +7 -2
- data/lib/git/commands/config_option_syntax/unset.rb +7 -4
- data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
- data/lib/git/commands/describe.rb +5 -4
- data/lib/git/commands/diff.rb +13 -12
- data/lib/git/commands/diff_files.rb +7 -6
- data/lib/git/commands/diff_index.rb +10 -7
- data/lib/git/commands/fetch.rb +6 -4
- data/lib/git/commands/fsck.rb +6 -4
- data/lib/git/commands/gc.rb +6 -4
- data/lib/git/commands/grep.rb +6 -5
- data/lib/git/commands/init.rb +6 -4
- data/lib/git/commands/log.rb +287 -285
- data/lib/git/commands/ls_files.rb +69 -65
- data/lib/git/commands/ls_remote.rb +62 -56
- data/lib/git/commands/ls_tree.rb +50 -46
- data/lib/git/commands/maintenance/register.rb +25 -23
- data/lib/git/commands/maintenance/run.rb +7 -2
- data/lib/git/commands/maintenance/start.rb +7 -2
- data/lib/git/commands/maintenance/stop.rb +7 -2
- data/lib/git/commands/maintenance/unregister.rb +7 -2
- data/lib/git/commands/merge/abort.rb +2 -2
- data/lib/git/commands/merge/continue.rb +2 -2
- data/lib/git/commands/merge/quit.rb +2 -2
- data/lib/git/commands/merge/start.rb +7 -2
- data/lib/git/commands/merge.rb +2 -2
- data/lib/git/commands/merge_base.rb +7 -2
- data/lib/git/commands/mv.rb +7 -2
- data/lib/git/commands/name_rev.rb +7 -2
- data/lib/git/commands/pull.rb +7 -2
- data/lib/git/commands/push.rb +7 -2
- data/lib/git/commands/read_tree.rb +7 -2
- data/lib/git/commands/remote/add.rb +7 -2
- data/lib/git/commands/remote/get_url.rb +4 -2
- data/lib/git/commands/remote/list.rb +4 -2
- data/lib/git/commands/remote/prune.rb +4 -2
- data/lib/git/commands/remote/remove.rb +4 -2
- data/lib/git/commands/remote/rename.rb +4 -2
- data/lib/git/commands/remote/set_branches.rb +9 -2
- data/lib/git/commands/remote/set_head.rb +12 -5
- data/lib/git/commands/remote/set_url.rb +9 -2
- data/lib/git/commands/remote/set_url_add.rb +11 -2
- data/lib/git/commands/remote/set_url_delete.rb +9 -2
- data/lib/git/commands/remote/show.rb +18 -12
- data/lib/git/commands/remote/update.rb +19 -12
- data/lib/git/commands/remote.rb +2 -2
- data/lib/git/commands/repack.rb +67 -63
- data/lib/git/commands/reset.rb +51 -44
- data/lib/git/commands/rev_parse.rb +135 -128
- data/lib/git/commands/revert/abort.rb +2 -2
- data/lib/git/commands/revert/continue.rb +7 -2
- data/lib/git/commands/revert/quit.rb +2 -2
- data/lib/git/commands/revert/skip.rb +2 -2
- data/lib/git/commands/revert/start.rb +7 -2
- data/lib/git/commands/revert.rb +2 -2
- data/lib/git/commands/rm.rb +35 -36
- data/lib/git/commands/show.rb +1 -1
- data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
- data/lib/git/commands/show_ref/exists.rb +15 -13
- data/lib/git/commands/show_ref/list.rb +39 -35
- data/lib/git/commands/show_ref/verify.rb +29 -27
- data/lib/git/commands/show_ref.rb +4 -4
- data/lib/git/commands/stash/apply.rb +31 -25
- data/lib/git/commands/stash/branch.rb +10 -8
- data/lib/git/commands/stash/clear.rb +7 -5
- data/lib/git/commands/stash/create.rb +10 -8
- data/lib/git/commands/stash/drop.rb +15 -9
- data/lib/git/commands/stash/list.rb +9 -5
- data/lib/git/commands/stash/pop.rb +21 -12
- data/lib/git/commands/stash/push.rb +20 -11
- data/lib/git/commands/stash/show.rb +21 -12
- data/lib/git/commands/stash/store.rb +19 -10
- data/lib/git/commands/stash.rb +2 -2
- data/lib/git/commands/status.rb +7 -2
- data/lib/git/commands/symbolic_ref/delete.rb +18 -14
- data/lib/git/commands/symbolic_ref/read.rb +24 -20
- data/lib/git/commands/symbolic_ref/update.rb +20 -17
- data/lib/git/commands/symbolic_ref.rb +4 -4
- data/lib/git/commands/tag/create.rb +45 -42
- data/lib/git/commands/tag/delete.rb +5 -3
- data/lib/git/commands/tag/list.rb +47 -44
- data/lib/git/commands/tag/verify.rb +12 -12
- data/lib/git/commands/tag.rb +2 -2
- data/lib/git/commands/update_ref/batch.rb +6 -1
- data/lib/git/commands/update_ref/delete.rb +19 -21
- data/lib/git/commands/update_ref/update.rb +22 -25
- data/lib/git/commands/update_ref.rb +4 -4
- data/lib/git/commands/version.rb +14 -11
- data/lib/git/commands/worktree/add.rb +50 -51
- data/lib/git/commands/worktree/list.rb +17 -17
- data/lib/git/commands/worktree/lock.rb +12 -12
- data/lib/git/commands/worktree/move.rb +16 -16
- data/lib/git/commands/worktree/prune.rb +2 -2
- data/lib/git/commands/worktree/remove.rb +2 -2
- data/lib/git/commands/worktree/repair.rb +2 -2
- data/lib/git/commands/worktree/unlock.rb +2 -2
- data/lib/git/commands/write_tree.rb +2 -2
- data/lib/git/commands.rb +4 -3
- data/lib/git/config.rb +47 -1
- data/lib/git/configuring.rb +89 -15
- data/lib/git/detached_head_info.rb +4 -1
- data/lib/git/diff.rb +2 -5
- data/lib/git/diff_file_numstat_info.rb +3 -1
- data/lib/git/diff_file_patch_info.rb +3 -1
- data/lib/git/diff_file_raw_info.rb +3 -1
- data/lib/git/diff_info.rb +8 -15
- data/lib/git/diff_path_status.rb +16 -3
- data/lib/git/diff_result.rb +3 -1
- data/lib/git/diff_stats.rb +15 -0
- data/lib/git/dirstat_info.rb +24 -8
- data/lib/git/encoding_utils.rb +32 -1
- data/lib/git/errors.rb +19 -9
- data/lib/git/escaped_path.rb +55 -3
- data/lib/git/execution_context/repository.rb +15 -0
- data/lib/git/execution_context.rb +76 -74
- data/lib/git/file_ref.rb +6 -3
- data/lib/git/fsck_object.rb +8 -0
- data/lib/git/fsck_result.rb +26 -15
- data/lib/git/log.rb +152 -5
- data/lib/git/object.rb +284 -8
- data/lib/git/parsers/branch.rb +18 -0
- data/lib/git/parsers/cat_file.rb +2 -2
- data/lib/git/parsers/diff.rb +213 -5
- data/lib/git/parsers/fsck.rb +11 -0
- data/lib/git/parsers/ls_remote.rb +1 -1
- data/lib/git/parsers/stash.rb +51 -0
- data/lib/git/parsers/tag.rb +38 -0
- data/lib/git/remote.rb +34 -2
- data/lib/git/repository/branching.rb +23 -21
- data/lib/git/repository/committing.rb +46 -6
- data/lib/git/repository/context_helpers.rb +45 -16
- data/lib/git/repository/diffing.rb +32 -23
- data/lib/git/repository/factories.rb +153 -28
- data/lib/git/repository/inspecting.rb +1 -1
- data/lib/git/repository/logging.rb +169 -30
- data/lib/git/repository/maintenance.rb +1 -1
- data/lib/git/repository/merging.rb +3 -3
- data/lib/git/repository/object_operations.rb +108 -14
- data/lib/git/repository/remote_operations.rb +150 -171
- data/lib/git/repository/shared_private.rb +7 -5
- data/lib/git/repository/staging.rb +36 -12
- data/lib/git/repository/stashing.rb +16 -16
- data/lib/git/repository/status_operations.rb +1 -1
- data/lib/git/repository/worktree_operations.rb +1 -1
- data/lib/git/repository.rb +287 -6
- data/lib/git/stash.rb +16 -21
- data/lib/git/stash_info.rb +4 -4
- data/lib/git/stashes.rb +20 -26
- data/lib/git/status.rb +25 -13
- data/lib/git/tag_delete_failure.rb +3 -0
- data/lib/git/tag_delete_result.rb +6 -3
- data/lib/git/tag_info.rb +1 -0
- data/lib/git/url.rb +12 -5
- data/lib/git/version.rb +6 -4
- data/lib/git/version_constraint.rb +4 -0
- data/lib/git.rb +400 -314
- data/redesign/3_architecture_implementation.md +81 -30
- data/redesign/Phase 4 - Step A.md +6 -0
- data/redesign/Phase 4 - Step B.md +921 -0
- data/redesign/Phase 4 - Step C.md +833 -0
- data/redesign/c1a-public-api-scope.tsv +256 -0
- data/redesign/phase-4-step-b-test-audit.tsv +485 -0
- data/tasks/yard.rake +24 -17
- metadata +24 -58
- data/commitlint.test +0 -4
- data/lib/git/args_builder.rb +0 -103
- data/lib/git/command_line_result.rb +0 -8
- data/lib/git/deprecation.rb +0 -9
- data/lib/git/repository/configuring.rb +0 -351
- data/tasks/test.rake +0 -25
- /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
- /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
|
@@ -17,7 +17,7 @@ module Git
|
|
|
17
17
|
#
|
|
18
18
|
# Included by {Git::Repository}.
|
|
19
19
|
#
|
|
20
|
-
# @api
|
|
20
|
+
# @api private
|
|
21
21
|
#
|
|
22
22
|
module Diffing
|
|
23
23
|
# Option keys accepted by {#diff_full}
|
|
@@ -133,10 +133,11 @@ module Git
|
|
|
133
133
|
# repo.diff_numstat('abc1234', 'def5678')
|
|
134
134
|
#
|
|
135
135
|
# @example Get working tree changes since HEAD
|
|
136
|
-
# repo.diff_numstat
|
|
137
|
-
#
|
|
138
|
-
#
|
|
139
|
-
# }
|
|
136
|
+
# repo.diff_numstat
|
|
137
|
+
# #=> {
|
|
138
|
+
# # total: { insertions: 5, deletions: 2, lines: 7, files: 1 },
|
|
139
|
+
# # files: { "lib/foo.rb" => { insertions: 5, deletions: 2 } }
|
|
140
|
+
# # }
|
|
140
141
|
#
|
|
141
142
|
# @example Get unstaged changes (index vs. working tree)
|
|
142
143
|
# repo.diff_numstat(nil) #=> { ... }
|
|
@@ -387,11 +388,6 @@ module Git
|
|
|
387
388
|
# (staging area) and the working directory. These are changes that have
|
|
388
389
|
# been made to tracked files but not yet staged.
|
|
389
390
|
#
|
|
390
|
-
# @note The field names in the returned hash are **legacy names** inherited
|
|
391
|
-
# from `Git::Lib#diff_files` and appear counterintuitive: `:mode_repo`
|
|
392
|
-
# and `:sha_repo` hold **index (staging area)** values, while
|
|
393
|
-
# `:mode_index` and `:sha_index` hold **working tree** values.
|
|
394
|
-
#
|
|
395
391
|
# @example List all files with unstaged changes
|
|
396
392
|
# repo.diff_files
|
|
397
393
|
# #=> {
|
|
@@ -418,6 +414,11 @@ module Git
|
|
|
418
414
|
#
|
|
419
415
|
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 1)
|
|
420
416
|
#
|
|
417
|
+
# @note The field names in the returned hash are **legacy names** inherited
|
|
418
|
+
# from `Git::Lib#diff_files` and appear counterintuitive: `:mode_repo`
|
|
419
|
+
# and `:sha_repo` hold **index (staging area)** values, while
|
|
420
|
+
# `:mode_index` and `:sha_index` hold **working tree** values.
|
|
421
|
+
#
|
|
421
422
|
# @see https://git-scm.com/docs/git-diff-files git-diff-files documentation
|
|
422
423
|
#
|
|
423
424
|
def diff_files
|
|
@@ -437,18 +438,6 @@ module Git
|
|
|
437
438
|
# This is equivalent to the 4.x `Git::Lib#diff_index` behavior, which also
|
|
438
439
|
# ran `git diff-index` without `--cached`.
|
|
439
440
|
#
|
|
440
|
-
# @note `git diff-index` without `--cached` uses the index as a stat cache:
|
|
441
|
-
# any file whose index entry differs from the tree is reported as changed,
|
|
442
|
-
# even when the on-disk working-tree content is byte-for-byte identical to
|
|
443
|
-
# the tree. A staged change that has been reverted in the working tree will
|
|
444
|
-
# therefore still appear in the result (because the index still differs from
|
|
445
|
-
# the tree).
|
|
446
|
-
#
|
|
447
|
-
# @note The field names in the returned hash are **legacy names** inherited
|
|
448
|
-
# from `Git::Lib#diff_index` and appear counterintuitive: `:mode_repo`
|
|
449
|
-
# and `:sha_repo` hold **tree (treeish)** values, while `:mode_index` and
|
|
450
|
-
# `:sha_index` hold **working tree** values.
|
|
451
|
-
#
|
|
452
441
|
# @example List all working-tree files that differ from HEAD
|
|
453
442
|
# repo.diff_index('HEAD')
|
|
454
443
|
# #=> {
|
|
@@ -478,6 +467,18 @@ module Git
|
|
|
478
467
|
#
|
|
479
468
|
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 1)
|
|
480
469
|
#
|
|
470
|
+
# @note `git diff-index` without `--cached` uses the index as a stat cache:
|
|
471
|
+
# any file whose index entry differs from the tree is reported as changed,
|
|
472
|
+
# even when the on-disk working-tree content is byte-for-byte identical to
|
|
473
|
+
# the tree. A staged change that has been reverted in the working tree will
|
|
474
|
+
# therefore still appear in the result (because the index still differs from
|
|
475
|
+
# the tree).
|
|
476
|
+
#
|
|
477
|
+
# @note The field names in the returned hash are **legacy names** inherited
|
|
478
|
+
# from `Git::Lib#diff_index` and appear counterintuitive: `:mode_repo`
|
|
479
|
+
# and `:sha_repo` hold **tree (treeish)** values, while `:mode_index` and
|
|
480
|
+
# `:sha_index` hold **working tree** values.
|
|
481
|
+
#
|
|
481
482
|
# @see https://git-scm.com/docs/git-diff-index git-diff-index documentation
|
|
482
483
|
#
|
|
483
484
|
def diff_index(treeish)
|
|
@@ -502,6 +503,12 @@ module Git
|
|
|
502
503
|
#
|
|
503
504
|
# @param opts [Hash] the options hash from {#diff_path_status}
|
|
504
505
|
#
|
|
506
|
+
# @option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
|
|
507
|
+
# primary path limiter value used as-is when present
|
|
508
|
+
#
|
|
509
|
+
# @option opts [String, Pathname, Array<String, Pathname>, nil] :path (nil)
|
|
510
|
+
# **deprecated** — fallback path limiter when `:path_limiter` is not provided
|
|
511
|
+
#
|
|
505
512
|
# @return [String, Pathname, Array<String, Pathname>, nil]
|
|
506
513
|
# the effective path limiter
|
|
507
514
|
#
|
|
@@ -545,7 +552,7 @@ module Git
|
|
|
545
552
|
#
|
|
546
553
|
# @param pathspecs [Array<String>, nil] path limiters
|
|
547
554
|
#
|
|
548
|
-
# @return [Git::
|
|
555
|
+
# @return [Git::CommandLine::Result] the result of calling `git diff`
|
|
549
556
|
#
|
|
550
557
|
def call_diff_command(execution_context, from, to, pathspecs)
|
|
551
558
|
Git::Commands::Diff.new(execution_context).call(
|
|
@@ -624,6 +631,7 @@ module Git
|
|
|
624
631
|
# Parses a single raw `git diff-files` output line into a path/entry pair
|
|
625
632
|
#
|
|
626
633
|
# @param line [String] a single non-empty line containing a tab character
|
|
634
|
+
#
|
|
627
635
|
# @param tab_pos [Integer] the index of the first tab in the line
|
|
628
636
|
#
|
|
629
637
|
# @return [Array(String, Hash)] two-element array of `[path, entry_hash]`
|
|
@@ -637,6 +645,7 @@ module Git
|
|
|
637
645
|
# Builds a single file-info hash for {#parse_diff_files_output}
|
|
638
646
|
#
|
|
639
647
|
# @param path [String] the file path
|
|
648
|
+
#
|
|
640
649
|
# @param parts [Array<String>] the whitespace-split fields from the info
|
|
641
650
|
# portion of the diff-files line: `[mode_src, mode_dest, sha_src,
|
|
642
651
|
# sha_dest, type]`
|
|
@@ -9,32 +9,31 @@ require 'pathname'
|
|
|
9
9
|
|
|
10
10
|
module Git
|
|
11
11
|
class Repository
|
|
12
|
-
#
|
|
12
|
+
# Implementation of the {Git} module factory entry points
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
14
|
+
# Provides `.open`, `.init`, `.clone`, and `.bare` — the four methods that
|
|
15
|
+
# construct a {Git::Repository}. Extended onto the {Git} module so that
|
|
16
|
+
# `Git.open(...)`, `Git.init(...)`, etc. resolve here.
|
|
16
17
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
# @api public
|
|
18
|
+
# @api private
|
|
20
19
|
#
|
|
21
20
|
module Factories # rubocop:disable Metrics/ModuleLength
|
|
22
21
|
# Clone a repository into a new directory
|
|
23
22
|
#
|
|
24
23
|
# @example Clone into the default directory
|
|
25
|
-
# repository = Git
|
|
24
|
+
# repository = Git.clone('https://github.com/ruby-git/ruby-git.git')
|
|
26
25
|
#
|
|
27
26
|
# @example Clone into a specific directory
|
|
28
27
|
# repo_url = 'https://github.com/ruby-git/ruby-git.git'
|
|
29
|
-
# repository = Git
|
|
28
|
+
# repository = Git.clone(repo_url, 'local')
|
|
30
29
|
#
|
|
31
30
|
# @example Clone a bare repository
|
|
32
31
|
# repo_url = 'https://github.com/ruby-git/ruby-git.git'
|
|
33
|
-
# repository = Git
|
|
32
|
+
# repository = Git.clone(repo_url, nil, bare: true)
|
|
34
33
|
#
|
|
35
|
-
# @param repository_url [String] the URL or path of the repository to clone
|
|
34
|
+
# @param repository_url [String, URI, Pathname] the URL or path of the repository to clone
|
|
36
35
|
#
|
|
37
|
-
# @param directory [String, nil] the local directory name to clone into;
|
|
36
|
+
# @param directory [String, Pathname, nil] the local directory name to clone into;
|
|
38
37
|
# git derives the name from the URL when `nil`
|
|
39
38
|
#
|
|
40
39
|
# @param options [Hash] options that control cloning
|
|
@@ -187,13 +186,13 @@ module Git
|
|
|
187
186
|
# Create an empty Git repository or reinitialize an existing one
|
|
188
187
|
#
|
|
189
188
|
# @example Initialize in the current directory
|
|
190
|
-
# repository = Git
|
|
189
|
+
# repository = Git.init
|
|
191
190
|
#
|
|
192
191
|
# @example Initialize in a specific directory
|
|
193
|
-
# repository = Git
|
|
192
|
+
# repository = Git.init('/path/to/project')
|
|
194
193
|
#
|
|
195
194
|
# @example Initialize a bare repository
|
|
196
|
-
# repository = Git
|
|
195
|
+
# repository = Git.init('/path/to/project.git', bare: true)
|
|
197
196
|
#
|
|
198
197
|
# @param directory [String] the directory to initialize; defaults to `'.'`
|
|
199
198
|
#
|
|
@@ -249,11 +248,8 @@ module Git
|
|
|
249
248
|
|
|
250
249
|
# Open a working copy at an existing path
|
|
251
250
|
#
|
|
252
|
-
# Note: this method opens working copies only. To open a bare repository, use
|
|
253
|
-
# `Git::Repository.bare`.
|
|
254
|
-
#
|
|
255
251
|
# @example Open the working copy in the current directory
|
|
256
|
-
# repository = Git
|
|
252
|
+
# repository = Git.open('.')
|
|
257
253
|
#
|
|
258
254
|
# @param working_dir [String] the path to the root of the working copy
|
|
259
255
|
#
|
|
@@ -288,6 +284,9 @@ module Git
|
|
|
288
284
|
# @raise [ArgumentError] if `working_dir` is not a directory or is not inside
|
|
289
285
|
# a git working tree
|
|
290
286
|
#
|
|
287
|
+
# @note This method opens working copies only. To open a bare repository, use
|
|
288
|
+
# `Git.bare`.
|
|
289
|
+
#
|
|
291
290
|
# @api public
|
|
292
291
|
#
|
|
293
292
|
def open(working_dir, options = {})
|
|
@@ -307,7 +306,7 @@ module Git
|
|
|
307
306
|
# Open an existing bare repository at `git_dir`
|
|
308
307
|
#
|
|
309
308
|
# @example Open a bare repository
|
|
310
|
-
# repository = Git
|
|
309
|
+
# repository = Git.bare('/path/to/repo.git')
|
|
311
310
|
#
|
|
312
311
|
# @param git_dir [String] the path to the bare repository directory
|
|
313
312
|
#
|
|
@@ -341,16 +340,27 @@ module Git
|
|
|
341
340
|
|
|
342
341
|
# Run the `git clone` command using a global execution context
|
|
343
342
|
#
|
|
344
|
-
# @param repository_url [String] the URL or path of the repository to clone
|
|
343
|
+
# @param repository_url [String, URI, Pathname] the URL or path of the repository to clone
|
|
345
344
|
#
|
|
346
|
-
# @param directory [String, nil] the local directory name to clone into
|
|
345
|
+
# @param directory [String, Pathname, nil] the local directory name to clone into
|
|
347
346
|
#
|
|
348
347
|
# @param opts [Hash] command-ready clone options
|
|
349
348
|
#
|
|
350
349
|
# @param context_opts [Hash] context options produced while preparing clone
|
|
351
350
|
# options
|
|
352
351
|
#
|
|
353
|
-
# @
|
|
352
|
+
# @option opts [Boolean, nil] :bare clone as a bare repository
|
|
353
|
+
#
|
|
354
|
+
# @option context_opts [String, :use_global_config] :binary_path path to
|
|
355
|
+
# the git binary
|
|
356
|
+
#
|
|
357
|
+
# @option context_opts [String, nil, :use_global_config] :git_ssh path to
|
|
358
|
+
# a custom SSH executable
|
|
359
|
+
#
|
|
360
|
+
# @option context_opts [Logger, nil] :logger logger used for clone
|
|
361
|
+
# operations
|
|
362
|
+
#
|
|
363
|
+
# @return [Git::CommandLine::Result] the result of running `git clone`
|
|
354
364
|
#
|
|
355
365
|
# @raise [ArgumentError] if unsupported options are provided
|
|
356
366
|
#
|
|
@@ -370,13 +380,23 @@ module Git
|
|
|
370
380
|
|
|
371
381
|
# Resolve repository paths from a completed clone result
|
|
372
382
|
#
|
|
373
|
-
# @param clone_result [Git::
|
|
383
|
+
# @param clone_result [Git::CommandLine::Result] the completed clone result
|
|
374
384
|
#
|
|
375
385
|
# @param opts [Hash] command-ready clone options
|
|
376
386
|
#
|
|
377
387
|
# @param context_opts [Hash] context options produced while preparing clone
|
|
378
388
|
# options
|
|
379
389
|
#
|
|
390
|
+
# @option opts [String, Pathname, nil] :chdir run `git clone` from within
|
|
391
|
+
# this directory
|
|
392
|
+
#
|
|
393
|
+
# @option opts [Boolean, nil] :bare clone as a bare repository
|
|
394
|
+
#
|
|
395
|
+
# @option opts [Boolean, nil] :mirror set up a mirror of the source
|
|
396
|
+
#
|
|
397
|
+
# @option context_opts [String, nil] :index custom index path for the
|
|
398
|
+
# returned repository
|
|
399
|
+
#
|
|
380
400
|
# @return [Hash{Symbol => (String, nil)}] resolved path hash
|
|
381
401
|
#
|
|
382
402
|
# @raise [Git::UnexpectedResultError] if the clone directory cannot be parsed
|
|
@@ -417,6 +437,12 @@ module Git
|
|
|
417
437
|
#
|
|
418
438
|
# @param options [Hash] the caller-supplied options hash
|
|
419
439
|
#
|
|
440
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
441
|
+
# git binary
|
|
442
|
+
#
|
|
443
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
444
|
+
# custom SSH executable
|
|
445
|
+
#
|
|
420
446
|
# @return [Hash] context defaults with two keys: `:binary_path`
|
|
421
447
|
# (`String` or `:use_global_config` — `nil` is not valid and raises
|
|
422
448
|
# `ArgumentError` in {Git::ExecutionContext#initialize}) and `:git_ssh`
|
|
@@ -437,6 +463,12 @@ module Git
|
|
|
437
463
|
#
|
|
438
464
|
# @param options [Hash] the caller-supplied options hash from {.open}
|
|
439
465
|
#
|
|
466
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
467
|
+
# git binary
|
|
468
|
+
#
|
|
469
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
470
|
+
# custom SSH executable
|
|
471
|
+
#
|
|
440
472
|
# @return [String] the absolute path to the root of the working tree
|
|
441
473
|
#
|
|
442
474
|
# @raise [ArgumentError] if `working_dir` is not inside a git working tree
|
|
@@ -454,12 +486,20 @@ module Git
|
|
|
454
486
|
#
|
|
455
487
|
# @param paths [Hash{Symbol => (String, nil)}] the resolved paths
|
|
456
488
|
#
|
|
489
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
490
|
+
# custom SSH executable
|
|
491
|
+
#
|
|
492
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
493
|
+
# git binary
|
|
494
|
+
#
|
|
495
|
+
# @option options [Logger, nil] :log logger used for git operations
|
|
496
|
+
#
|
|
457
497
|
# @return [Git::Repository] the constructed repository
|
|
458
498
|
#
|
|
459
499
|
# @api private
|
|
460
500
|
#
|
|
461
501
|
def from_paths(options, paths)
|
|
462
|
-
new(execution_context: Git::ExecutionContext::Repository.from_hash(
|
|
502
|
+
Git::Repository.new(execution_context: Git::ExecutionContext::Repository.from_hash(
|
|
463
503
|
options.merge(paths), logger: options[:log]
|
|
464
504
|
))
|
|
465
505
|
end
|
|
@@ -475,6 +515,8 @@ module Git
|
|
|
475
515
|
#
|
|
476
516
|
# @param options [Hash] raw caller-supplied options
|
|
477
517
|
#
|
|
518
|
+
# @option options [Boolean, nil] :bare clone as a bare repository
|
|
519
|
+
#
|
|
478
520
|
# @return [Array<Hash>] a two-element tuple `[command_opts, context_opts]`
|
|
479
521
|
#
|
|
480
522
|
# @api private
|
|
@@ -494,6 +536,17 @@ module Git
|
|
|
494
536
|
#
|
|
495
537
|
# @param opts [Hash] clone options (mutated in place)
|
|
496
538
|
#
|
|
539
|
+
# @option opts [Logger, nil] :log logger used for clone operations
|
|
540
|
+
#
|
|
541
|
+
# @option opts [String, nil, :use_global_config] :git_ssh path to a
|
|
542
|
+
# custom SSH executable
|
|
543
|
+
#
|
|
544
|
+
# @option opts [String, :use_global_config] :binary_path path to the git
|
|
545
|
+
# binary
|
|
546
|
+
#
|
|
547
|
+
# @option opts [String, nil] :index custom index path for the returned
|
|
548
|
+
# repository
|
|
549
|
+
#
|
|
497
550
|
# @return [Hash{Symbol => Object}] context options for clone setup
|
|
498
551
|
#
|
|
499
552
|
# @api private
|
|
@@ -511,6 +564,8 @@ module Git
|
|
|
511
564
|
#
|
|
512
565
|
# @param opts [Hash] clone options (mutated in place)
|
|
513
566
|
#
|
|
567
|
+
# @option opts [String, nil] :repository alternate git directory path
|
|
568
|
+
#
|
|
514
569
|
# @return [void] mutates `opts` in place
|
|
515
570
|
#
|
|
516
571
|
# @api private
|
|
@@ -545,7 +600,23 @@ module Git
|
|
|
545
600
|
#
|
|
546
601
|
# @param options [Hash] the normalized options hash (after alias resolution)
|
|
547
602
|
#
|
|
548
|
-
# @
|
|
603
|
+
# @option options [Boolean, nil] :bare create a bare repository at
|
|
604
|
+
# `directory`
|
|
605
|
+
#
|
|
606
|
+
# @option options [String, nil] :initial_branch the name for the initial
|
|
607
|
+
# branch
|
|
608
|
+
#
|
|
609
|
+
# @option options [String, nil] :repository path for the `.git` directory
|
|
610
|
+
#
|
|
611
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
612
|
+
# git binary
|
|
613
|
+
#
|
|
614
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
615
|
+
# custom SSH executable
|
|
616
|
+
#
|
|
617
|
+
# @option options [Logger, nil] :log logger used for git operations
|
|
618
|
+
#
|
|
619
|
+
# @return [Git::CommandLine::Result] the result of running `git init`
|
|
549
620
|
#
|
|
550
621
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
551
622
|
#
|
|
@@ -565,6 +636,22 @@ module Git
|
|
|
565
636
|
#
|
|
566
637
|
# @param options [Hash] the normalized options hash
|
|
567
638
|
#
|
|
639
|
+
# @option options [Boolean, nil] :bare create a bare repository at
|
|
640
|
+
# `directory`
|
|
641
|
+
#
|
|
642
|
+
# @option options [String, nil] :repository path for the `.git` directory
|
|
643
|
+
#
|
|
644
|
+
# @option options [String, nil] :index custom index path for the returned
|
|
645
|
+
# repository
|
|
646
|
+
#
|
|
647
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
648
|
+
# git binary
|
|
649
|
+
#
|
|
650
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
651
|
+
# custom SSH executable
|
|
652
|
+
#
|
|
653
|
+
# @option options [Logger, nil] :log logger used for git operations
|
|
654
|
+
#
|
|
568
655
|
# @return [Git::Repository] the repository opened after initialization
|
|
569
656
|
#
|
|
570
657
|
# @api private
|
|
@@ -579,6 +666,14 @@ module Git
|
|
|
579
666
|
#
|
|
580
667
|
# @param options [Hash] the normalized options hash
|
|
581
668
|
#
|
|
669
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
670
|
+
# custom SSH executable
|
|
671
|
+
#
|
|
672
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
673
|
+
# git binary
|
|
674
|
+
#
|
|
675
|
+
# @option options [Logger, nil] :log logger used for git operations
|
|
676
|
+
#
|
|
582
677
|
# @return [Hash{Symbol => Object}] options accepted by {.open} and {.bare}
|
|
583
678
|
#
|
|
584
679
|
# @api private
|
|
@@ -596,6 +691,19 @@ module Git
|
|
|
596
691
|
#
|
|
597
692
|
# @param options [Hash] the normalized options hash
|
|
598
693
|
#
|
|
694
|
+
# @option options [String, nil, :use_global_config] :git_ssh path to a
|
|
695
|
+
# custom SSH executable
|
|
696
|
+
#
|
|
697
|
+
# @option options [String, :use_global_config] :binary_path path to the
|
|
698
|
+
# git binary
|
|
699
|
+
#
|
|
700
|
+
# @option options [Logger, nil] :log logger used for git operations
|
|
701
|
+
#
|
|
702
|
+
# @option options [String, nil] :index custom index path for the returned
|
|
703
|
+
# repository
|
|
704
|
+
#
|
|
705
|
+
# @option options [String, nil] :repository path for the `.git` directory
|
|
706
|
+
#
|
|
599
707
|
# @return [Hash{Symbol => Object}] options accepted by {.open}
|
|
600
708
|
#
|
|
601
709
|
# @api private
|
|
@@ -628,6 +736,12 @@ module Git
|
|
|
628
736
|
#
|
|
629
737
|
# @param opts [Hash] clone options (mutated in place)
|
|
630
738
|
#
|
|
739
|
+
# @option opts [String, Pathname, nil] :path deprecated; use `:chdir`
|
|
740
|
+
# instead
|
|
741
|
+
#
|
|
742
|
+
# @option opts [String, Pathname, nil] :chdir run `git clone` from within
|
|
743
|
+
# this directory
|
|
744
|
+
#
|
|
631
745
|
# @return [void] mutates `opts` in place
|
|
632
746
|
#
|
|
633
747
|
# @api private
|
|
@@ -636,7 +750,7 @@ module Git
|
|
|
636
750
|
return unless opts.key?(:path)
|
|
637
751
|
|
|
638
752
|
if defined?(Git::Deprecation)
|
|
639
|
-
Git::Deprecation.warn('The :path option for Git
|
|
753
|
+
Git::Deprecation.warn('The :path option for Git.clone is deprecated, use :chdir instead')
|
|
640
754
|
end
|
|
641
755
|
path = opts.delete(:path)
|
|
642
756
|
opts[:chdir] ||= path
|
|
@@ -646,6 +760,12 @@ module Git
|
|
|
646
760
|
#
|
|
647
761
|
# @param opts [Hash] clone options (mutated in place)
|
|
648
762
|
#
|
|
763
|
+
# @option opts [Boolean, nil] :recursive deprecated; use
|
|
764
|
+
# `:recurse_submodules` instead
|
|
765
|
+
#
|
|
766
|
+
# @option opts [Boolean, String, Array<String>, nil] :recurse_submodules
|
|
767
|
+
# initialize submodules after cloning
|
|
768
|
+
#
|
|
649
769
|
# @return [void] mutates `opts` in place
|
|
650
770
|
#
|
|
651
771
|
# @api private
|
|
@@ -655,7 +775,7 @@ module Git
|
|
|
655
775
|
|
|
656
776
|
if defined?(Git::Deprecation)
|
|
657
777
|
Git::Deprecation.warn(
|
|
658
|
-
'The :recursive option for Git
|
|
778
|
+
'The :recursive option for Git.clone is deprecated, use :recurse_submodules instead'
|
|
659
779
|
)
|
|
660
780
|
end
|
|
661
781
|
opts[:recurse_submodules] = opts.delete(:recursive)
|
|
@@ -665,6 +785,11 @@ module Git
|
|
|
665
785
|
#
|
|
666
786
|
# @param opts [Hash] clone options (mutated in place)
|
|
667
787
|
#
|
|
788
|
+
# @option opts [String, nil] :remote deprecated; use `:origin` instead
|
|
789
|
+
#
|
|
790
|
+
# @option opts [String, nil] :origin remote name to use instead of
|
|
791
|
+
# `origin`
|
|
792
|
+
#
|
|
668
793
|
# @return [void] mutates `opts` in place
|
|
669
794
|
#
|
|
670
795
|
# @api private
|
|
@@ -673,7 +798,7 @@ module Git
|
|
|
673
798
|
return unless opts.key?(:remote)
|
|
674
799
|
|
|
675
800
|
if defined?(Git::Deprecation)
|
|
676
|
-
Git::Deprecation.warn('The :remote option for Git
|
|
801
|
+
Git::Deprecation.warn('The :remote option for Git.clone is deprecated, use :origin instead')
|
|
677
802
|
end
|
|
678
803
|
opts[:origin] = opts.delete(:remote)
|
|
679
804
|
end
|