git 4.3.2 → 5.0.0.beta.1
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/.github/copilot-instructions.md +67 -2705
- data/.github/pull_request_template.md +3 -1
- data/.github/skills/breaking-change-analysis/SKILL.md +102 -0
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +264 -0
- data/.github/skills/command-implementation/REFERENCE.md +993 -0
- data/.github/skills/command-implementation/SKILL.md +229 -0
- data/.github/skills/command-test-conventions/SKILL.md +660 -0
- data/.github/skills/command-yard-documentation/SKILL.md +426 -0
- data/.github/skills/dependency-management/SKILL.md +72 -0
- data/.github/skills/development-workflow/SKILL.md +506 -0
- data/.github/skills/extract-command-from-lib/SKILL.md +487 -0
- data/.github/skills/extract-facade-from-base-lib/SKILL.md +586 -0
- data/.github/skills/facade-implementation/REFERENCE.md +840 -0
- data/.github/skills/facade-implementation/SKILL.md +260 -0
- data/.github/skills/facade-test-conventions/SKILL.md +380 -0
- data/.github/skills/facade-yard-documentation/SKILL.md +429 -0
- data/.github/skills/make-skill-template/SKILL.md +176 -0
- data/.github/skills/pr-readiness-review/SKILL.md +185 -0
- data/.github/skills/project-context/SKILL.md +313 -0
- data/.github/skills/pull-request-review/SKILL.md +168 -0
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +131 -0
- data/.github/skills/release-management/SKILL.md +125 -0
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +788 -0
- data/.github/skills/review-arguments-dsl/SKILL.md +214 -0
- data/.github/skills/review-backward-compatibility/SKILL.md +275 -0
- data/.github/skills/review-cross-command-consistency/SKILL.md +139 -0
- data/.github/skills/reviewing-skills/SKILL.md +189 -0
- data/.github/skills/rspec-unit-testing-standards/SKILL.md +639 -0
- data/.github/skills/tdd-refactor-step/SKILL.md +236 -0
- data/.github/skills/test-debugging/SKILL.md +160 -0
- data/.github/skills/yard-documentation/SKILL.md +793 -0
- data/.github/workflows/continuous_integration.yml +3 -2
- data/.github/workflows/enforce_conventional_commits.yml +1 -1
- data/.github/workflows/experimental_continuous_integration.yml +2 -2
- data/.github/workflows/release.yml +3 -4
- data/.gitignore +8 -0
- data/.husky/pre-commit +13 -0
- data/.release-please-manifest.json +1 -1
- data/.rspec +3 -0
- data/.rubocop.yml +7 -3
- data/.rubocop_todo.yml +23 -5
- data/.yardopts +1 -0
- data/CHANGELOG.md +0 -40
- data/CONTRIBUTING.md +694 -53
- data/README.md +17 -5
- data/Rakefile +61 -9
- data/commitlint.test +4 -0
- data/git.gemspec +14 -8
- data/lib/git/args_builder.rb +0 -8
- data/lib/git/base.rb +486 -410
- data/lib/git/branch.rb +380 -43
- data/lib/git/branch_delete_failure.rb +31 -0
- data/lib/git/branch_delete_result.rb +63 -0
- data/lib/git/branch_info.rb +178 -0
- data/lib/git/branches.rb +130 -24
- data/lib/git/command_line/base.rb +245 -0
- data/lib/git/command_line/capturing.rb +249 -0
- data/lib/git/command_line/result.rb +96 -0
- data/lib/git/command_line/streaming.rb +194 -0
- data/lib/git/command_line.rb +43 -322
- data/lib/git/command_line_result.rb +4 -88
- data/lib/git/commands/add.rb +131 -0
- data/lib/git/commands/am/abort.rb +43 -0
- data/lib/git/commands/am/apply.rb +252 -0
- data/lib/git/commands/am/continue.rb +43 -0
- data/lib/git/commands/am/quit.rb +43 -0
- data/lib/git/commands/am/retry.rb +47 -0
- data/lib/git/commands/am/show_current_patch.rb +64 -0
- data/lib/git/commands/am/skip.rb +42 -0
- data/lib/git/commands/am.rb +33 -0
- data/lib/git/commands/apply.rb +237 -0
- data/lib/git/commands/archive/list_formats.rb +46 -0
- data/lib/git/commands/archive.rb +140 -0
- data/lib/git/commands/arguments.rb +3510 -0
- data/lib/git/commands/base.rb +403 -0
- data/lib/git/commands/branch/copy.rb +94 -0
- data/lib/git/commands/branch/create.rb +173 -0
- data/lib/git/commands/branch/delete.rb +80 -0
- data/lib/git/commands/branch/list.rb +162 -0
- data/lib/git/commands/branch/move.rb +94 -0
- data/lib/git/commands/branch/set_upstream.rb +86 -0
- data/lib/git/commands/branch/show_current.rb +49 -0
- data/lib/git/commands/branch/unset_upstream.rb +57 -0
- data/lib/git/commands/branch.rb +34 -0
- data/lib/git/commands/cat_file/batch.rb +364 -0
- data/lib/git/commands/cat_file/filtered.rb +105 -0
- data/lib/git/commands/cat_file/raw.rb +210 -0
- data/lib/git/commands/cat_file.rb +49 -0
- data/lib/git/commands/checkout/branch.rb +151 -0
- data/lib/git/commands/checkout/files.rb +115 -0
- data/lib/git/commands/checkout.rb +38 -0
- data/lib/git/commands/checkout_index.rb +105 -0
- data/lib/git/commands/clean.rb +100 -0
- data/lib/git/commands/clone.rb +240 -0
- data/lib/git/commands/commit.rb +272 -0
- data/lib/git/commands/commit_tree.rb +100 -0
- data/lib/git/commands/config_option_syntax/add.rb +83 -0
- data/lib/git/commands/config_option_syntax/get.rb +117 -0
- data/lib/git/commands/config_option_syntax/get_all.rb +115 -0
- data/lib/git/commands/config_option_syntax/get_color.rb +91 -0
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +93 -0
- data/lib/git/commands/config_option_syntax/get_regexp.rb +115 -0
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +102 -0
- data/lib/git/commands/config_option_syntax/list.rb +107 -0
- data/lib/git/commands/config_option_syntax/remove_section.rb +74 -0
- data/lib/git/commands/config_option_syntax/rename_section.rb +78 -0
- data/lib/git/commands/config_option_syntax/replace_all.rb +104 -0
- data/lib/git/commands/config_option_syntax/set.rb +114 -0
- data/lib/git/commands/config_option_syntax/unset.rb +89 -0
- data/lib/git/commands/config_option_syntax/unset_all.rb +89 -0
- data/lib/git/commands/config_option_syntax.rb +56 -0
- data/lib/git/commands/describe.rb +155 -0
- data/lib/git/commands/diff.rb +656 -0
- data/lib/git/commands/diff_files.rb +518 -0
- data/lib/git/commands/diff_index.rb +496 -0
- data/lib/git/commands/fetch.rb +352 -0
- data/lib/git/commands/fsck.rb +136 -0
- data/lib/git/commands/gc.rb +132 -0
- data/lib/git/commands/grep.rb +338 -0
- data/lib/git/commands/init.rb +99 -0
- data/lib/git/commands/log.rb +632 -0
- data/lib/git/commands/ls_files.rb +191 -0
- data/lib/git/commands/ls_remote.rb +155 -0
- data/lib/git/commands/ls_tree.rb +131 -0
- data/lib/git/commands/maintenance/register.rb +75 -0
- data/lib/git/commands/maintenance/run.rb +104 -0
- data/lib/git/commands/maintenance/start.rb +66 -0
- data/lib/git/commands/maintenance/stop.rb +55 -0
- data/lib/git/commands/maintenance/unregister.rb +79 -0
- data/lib/git/commands/maintenance.rb +31 -0
- data/lib/git/commands/merge/abort.rb +44 -0
- data/lib/git/commands/merge/continue.rb +44 -0
- data/lib/git/commands/merge/quit.rb +46 -0
- data/lib/git/commands/merge/start.rb +245 -0
- data/lib/git/commands/merge.rb +28 -0
- data/lib/git/commands/merge_base.rb +86 -0
- data/lib/git/commands/mv.rb +77 -0
- data/lib/git/commands/name_rev.rb +114 -0
- data/lib/git/commands/pull.rb +377 -0
- data/lib/git/commands/push.rb +246 -0
- data/lib/git/commands/read_tree.rb +149 -0
- data/lib/git/commands/remote/add.rb +91 -0
- data/lib/git/commands/remote/get_url.rb +66 -0
- data/lib/git/commands/remote/list.rb +54 -0
- data/lib/git/commands/remote/prune.rb +61 -0
- data/lib/git/commands/remote/remove.rb +52 -0
- data/lib/git/commands/remote/rename.rb +69 -0
- data/lib/git/commands/remote/set_branches.rb +63 -0
- data/lib/git/commands/remote/set_head.rb +82 -0
- data/lib/git/commands/remote/set_url.rb +71 -0
- data/lib/git/commands/remote/set_url_add.rb +61 -0
- data/lib/git/commands/remote/set_url_delete.rb +64 -0
- data/lib/git/commands/remote/show.rb +71 -0
- data/lib/git/commands/remote/update.rb +72 -0
- data/lib/git/commands/remote.rb +42 -0
- data/lib/git/commands/repack.rb +277 -0
- data/lib/git/commands/reset.rb +147 -0
- data/lib/git/commands/rev_parse.rb +297 -0
- data/lib/git/commands/revert/abort.rb +45 -0
- data/lib/git/commands/revert/continue.rb +57 -0
- data/lib/git/commands/revert/quit.rb +47 -0
- data/lib/git/commands/revert/skip.rb +44 -0
- data/lib/git/commands/revert/start.rb +153 -0
- data/lib/git/commands/revert.rb +29 -0
- data/lib/git/commands/rm.rb +114 -0
- data/lib/git/commands/show.rb +632 -0
- data/lib/git/commands/show_ref/exclude_existing.rb +120 -0
- data/lib/git/commands/show_ref/exists.rb +78 -0
- data/lib/git/commands/show_ref/list.rb +145 -0
- data/lib/git/commands/show_ref/verify.rb +120 -0
- data/lib/git/commands/show_ref.rb +42 -0
- data/lib/git/commands/stash/apply.rb +75 -0
- data/lib/git/commands/stash/branch.rb +65 -0
- data/lib/git/commands/stash/clear.rb +41 -0
- data/lib/git/commands/stash/create.rb +58 -0
- data/lib/git/commands/stash/drop.rb +67 -0
- data/lib/git/commands/stash/list.rb +39 -0
- data/lib/git/commands/stash/pop.rb +78 -0
- data/lib/git/commands/stash/push.rb +103 -0
- data/lib/git/commands/stash/show.rb +149 -0
- data/lib/git/commands/stash/store.rb +63 -0
- data/lib/git/commands/stash.rb +38 -0
- data/lib/git/commands/status.rb +169 -0
- data/lib/git/commands/symbolic_ref/delete.rb +68 -0
- data/lib/git/commands/symbolic_ref/read.rb +95 -0
- data/lib/git/commands/symbolic_ref/update.rb +76 -0
- data/lib/git/commands/symbolic_ref.rb +38 -0
- data/lib/git/commands/tag/create.rb +139 -0
- data/lib/git/commands/tag/delete.rb +55 -0
- data/lib/git/commands/tag/list.rb +143 -0
- data/lib/git/commands/tag/verify.rb +71 -0
- data/lib/git/commands/tag.rb +26 -0
- data/lib/git/commands/update_ref/batch.rb +140 -0
- data/lib/git/commands/update_ref/delete.rb +92 -0
- data/lib/git/commands/update_ref/update.rb +106 -0
- data/lib/git/commands/update_ref.rb +42 -0
- data/lib/git/commands/version.rb +52 -0
- data/lib/git/commands/worktree/add.rb +140 -0
- data/lib/git/commands/worktree/list.rb +64 -0
- data/lib/git/commands/worktree/lock.rb +58 -0
- data/lib/git/commands/worktree/management_base.rb +51 -0
- data/lib/git/commands/worktree/move.rb +66 -0
- data/lib/git/commands/worktree/prune.rb +67 -0
- data/lib/git/commands/worktree/remove.rb +63 -0
- data/lib/git/commands/worktree/repair.rb +76 -0
- data/lib/git/commands/worktree/unlock.rb +47 -0
- data/lib/git/commands/worktree.rb +43 -0
- data/lib/git/commands/write_tree.rb +68 -0
- data/lib/git/commands.rb +89 -0
- data/lib/git/detached_head_info.rb +54 -0
- data/lib/git/diff.rb +297 -7
- data/lib/git/diff_file_numstat_info.rb +29 -0
- data/lib/git/diff_file_patch_info.rb +134 -0
- data/lib/git/diff_file_raw_info.rb +127 -0
- data/lib/git/diff_info.rb +169 -0
- data/lib/git/diff_path_status.rb +78 -19
- data/lib/git/diff_result.rb +32 -0
- data/lib/git/diff_stats.rb +59 -14
- data/lib/git/dirstat_info.rb +86 -0
- data/lib/git/errors.rb +65 -2
- data/lib/git/execution_context/global.rb +56 -0
- data/lib/git/execution_context/repository.rb +147 -0
- data/lib/git/execution_context.rb +482 -0
- data/lib/git/file_ref.rb +74 -0
- data/lib/git/fsck_object.rb +9 -9
- data/lib/git/fsck_result.rb +1 -1
- data/lib/git/lib.rb +1606 -1028
- data/lib/git/log.rb +15 -2
- data/lib/git/object.rb +92 -22
- data/lib/git/parsers/branch.rb +224 -0
- data/lib/git/parsers/cat_file.rb +111 -0
- data/lib/git/parsers/diff.rb +585 -0
- data/lib/git/parsers/fsck.rb +133 -0
- data/lib/git/parsers/grep.rb +42 -0
- data/lib/git/parsers/ls_tree.rb +58 -0
- data/lib/git/parsers/stash.rb +208 -0
- data/lib/git/parsers/tag.rb +257 -0
- data/lib/git/remote.rb +133 -9
- data/lib/git/repository/branching.rb +572 -0
- data/lib/git/repository/committing.rb +191 -0
- data/lib/git/repository/configuring.rb +156 -0
- data/lib/git/repository/diffing.rb +775 -0
- data/lib/git/repository/inspecting.rb +153 -0
- data/lib/git/repository/logging.rb +247 -0
- data/lib/git/repository/merging.rb +295 -0
- data/lib/git/repository/object_operations.rb +1101 -0
- data/lib/git/repository/path_resolver.rb +207 -0
- data/lib/git/repository/remote_operations.rb +753 -0
- data/lib/git/repository/shared_private.rb +51 -0
- data/lib/git/repository/staging.rb +390 -0
- data/lib/git/repository/stashing.rb +107 -0
- data/lib/git/repository/status_operations.rb +180 -0
- data/lib/git/repository/worktree_operations.rb +159 -0
- data/lib/git/repository.rb +264 -1
- data/lib/git/stash.rb +85 -4
- data/lib/git/stash_info.rb +104 -0
- data/lib/git/stashes.rb +130 -13
- data/lib/git/status.rb +224 -18
- data/lib/git/tag_delete_failure.rb +31 -0
- data/lib/git/tag_delete_result.rb +63 -0
- data/lib/git/tag_info.rb +105 -0
- data/lib/git/version.rb +109 -2
- data/lib/git/version_constraint.rb +81 -0
- data/lib/git/worktree.rb +120 -5
- data/lib/git/worktrees.rb +107 -7
- data/lib/git.rb +114 -18
- data/redesign/1_architecture_existing.md +54 -18
- data/redesign/2_architecture_redesign.md +365 -46
- data/redesign/3_architecture_implementation.md +1451 -54
- data/tasks/gem_tasks.rake +4 -0
- data/tasks/npm_tasks.rake +7 -0
- data/tasks/rspec.rake +48 -0
- data/tasks/test.rake +13 -1
- data/tasks/yard.rake +34 -7
- metadata +349 -20
- data/lib/git/index.rb +0 -6
- data/lib/git/path.rb +0 -38
- data/lib/git/working_directory.rb +0 -6
- /data/{release-please-config.json → .release-please-config.json} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'cat_file/batch'
|
|
4
|
+
require_relative 'cat_file/filtered'
|
|
5
|
+
require_relative 'cat_file/raw'
|
|
6
|
+
|
|
7
|
+
module Git
|
|
8
|
+
module Commands
|
|
9
|
+
# Commands for reading git object store content via `git cat-file`
|
|
10
|
+
#
|
|
11
|
+
# This module contains command classes split by invocation protocol:
|
|
12
|
+
#
|
|
13
|
+
# - {CatFile::Raw} — single object as a CLI argument; raw content, type, size, or
|
|
14
|
+
# existence check (`-e`, `-t`, `-s`, `-p`, `<type>`)
|
|
15
|
+
# - {CatFile::Filtered} — single object as a CLI argument; content after
|
|
16
|
+
# `.gitattributes` filter processing (`--textconv`, `--filters`)
|
|
17
|
+
# - {CatFile::Batch} — objects fed via stdin; all batch streaming modes
|
|
18
|
+
# (`--batch`, `--batch-check`, `--batch-command`)
|
|
19
|
+
#
|
|
20
|
+
# @api private
|
|
21
|
+
#
|
|
22
|
+
# @see https://git-scm.com/docs/git-cat-file git-cat-file documentation
|
|
23
|
+
#
|
|
24
|
+
# @example Check whether an object exists
|
|
25
|
+
# cmd = Git::Commands::CatFile::Raw.new(lib)
|
|
26
|
+
# result = cmd.call('HEAD', e: true)
|
|
27
|
+
# result.status.exitstatus # => 0 (exists) or 1 (not found)
|
|
28
|
+
#
|
|
29
|
+
# @example Pretty-print a single object
|
|
30
|
+
# cmd = Git::Commands::CatFile::Raw.new(lib)
|
|
31
|
+
# result = cmd.call('HEAD', p: true)
|
|
32
|
+
# result.stdout
|
|
33
|
+
# # => "tree abc1234...\nauthor ...\n\nCommit message\n"
|
|
34
|
+
#
|
|
35
|
+
# @example Fetch content after working-tree filters
|
|
36
|
+
# cmd = Git::Commands::CatFile::Filtered.new(lib)
|
|
37
|
+
# result = cmd.call('HEAD:README.md', filters: true)
|
|
38
|
+
# result.stdout
|
|
39
|
+
#
|
|
40
|
+
# @example Fetch metadata for several objects via batch
|
|
41
|
+
# cmd = Git::Commands::CatFile::Batch.new(lib)
|
|
42
|
+
# result = cmd.call('HEAD', 'v1.0', batch_check: true)
|
|
43
|
+
# result.stdout
|
|
44
|
+
# # => "abc1234... commit 250\nabc5678... tag 143\n"
|
|
45
|
+
#
|
|
46
|
+
module CatFile
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module Checkout
|
|
8
|
+
# Implements the `git checkout` command for switching branches
|
|
9
|
+
#
|
|
10
|
+
# This command switches branches by updating the index and working tree
|
|
11
|
+
# to match the specified branch, and updating HEAD to point to that branch.
|
|
12
|
+
# It can also create new branches with the `-b` or `-B` options.
|
|
13
|
+
#
|
|
14
|
+
# @example Typical usage
|
|
15
|
+
# checkout = Git::Commands::Checkout::Branch.new(execution_context)
|
|
16
|
+
# checkout.call('main')
|
|
17
|
+
# checkout.call(b: 'feature-branch')
|
|
18
|
+
# checkout.call('origin/main', b: 'feature-branch', track: true)
|
|
19
|
+
# checkout.call('abc123', detach: true)
|
|
20
|
+
# checkout.call('main', force: true)
|
|
21
|
+
#
|
|
22
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-checkout/2.53.0
|
|
23
|
+
#
|
|
24
|
+
# @see Git::Commands::Checkout
|
|
25
|
+
#
|
|
26
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
#
|
|
30
|
+
class Branch < Git::Commands::Base
|
|
31
|
+
arguments do
|
|
32
|
+
literal 'checkout'
|
|
33
|
+
flag_option %i[quiet q]
|
|
34
|
+
flag_option :progress, negatable: true
|
|
35
|
+
flag_option %i[force f]
|
|
36
|
+
value_option :b
|
|
37
|
+
value_option :B
|
|
38
|
+
flag_or_value_option %i[track t], negatable: true, inline: true
|
|
39
|
+
flag_option :guess, negatable: true
|
|
40
|
+
flag_option :l
|
|
41
|
+
flag_option %i[detach d]
|
|
42
|
+
value_option :orphan
|
|
43
|
+
flag_option %i[merge m]
|
|
44
|
+
flag_option :ignore_other_worktrees
|
|
45
|
+
flag_option :overwrite_ignore, negatable: true
|
|
46
|
+
|
|
47
|
+
# --recurse-submodules is technically available but has no effect on branch
|
|
48
|
+
# switching in older git versions. Included for completeness per the man page.
|
|
49
|
+
flag_option :recurse_submodules, negatable: true
|
|
50
|
+
|
|
51
|
+
execution_option :chdir
|
|
52
|
+
|
|
53
|
+
operand :branch
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @!method call(*, **)
|
|
57
|
+
#
|
|
58
|
+
# @overload call(branch = nil, **options)
|
|
59
|
+
#
|
|
60
|
+
# Execute the git checkout command for branch switching
|
|
61
|
+
#
|
|
62
|
+
# @param branch [String, nil] the branch name, commit SHA, or ref to check
|
|
63
|
+
# out; when used with branch creation options (`:b`, `:B`, `:orphan`)
|
|
64
|
+
# this becomes the start point
|
|
65
|
+
#
|
|
66
|
+
# @param options [Hash] command options
|
|
67
|
+
#
|
|
68
|
+
# @option options [Boolean, nil] :quiet (nil) suppress feedback messages
|
|
69
|
+
#
|
|
70
|
+
# Alias: `:q`
|
|
71
|
+
#
|
|
72
|
+
# @option options [Boolean, nil] :progress (nil) force progress reporting even
|
|
73
|
+
# when not attached to a terminal (`--progress`)
|
|
74
|
+
#
|
|
75
|
+
# @option options [Boolean, nil] :no_progress (nil) disable progress reporting
|
|
76
|
+
# even when attached to a terminal (`--no-progress`)
|
|
77
|
+
#
|
|
78
|
+
# @option options [Boolean, nil] :force (nil) proceed even if the index or
|
|
79
|
+
# working tree differs from HEAD; discards local changes and untracked
|
|
80
|
+
# files that are in the way
|
|
81
|
+
#
|
|
82
|
+
# Alias: `:f`
|
|
83
|
+
#
|
|
84
|
+
# @option options [String] :b (nil) create a new branch with this name and
|
|
85
|
+
# switch to it; the positional `branch` argument becomes the start point
|
|
86
|
+
#
|
|
87
|
+
# @option options [String] :B (nil) like `:b`, but reset the branch to the
|
|
88
|
+
# start point if it already exists
|
|
89
|
+
#
|
|
90
|
+
# @option options [Boolean, String, nil] :track (nil) set up upstream tracking
|
|
91
|
+
# configuration; `true` emits `--track`, `'direct'` emits
|
|
92
|
+
# `--track=direct`, `'inherit'` emits `--track=inherit` (`--track`)
|
|
93
|
+
#
|
|
94
|
+
# Alias: `:t`
|
|
95
|
+
#
|
|
96
|
+
# @option options [Boolean, nil] :no_track (nil) do not set up branch tracking
|
|
97
|
+
# even if `branch.autoSetupMerge` is configured (`--no-track`)
|
|
98
|
+
#
|
|
99
|
+
# @option options [Boolean, nil] :guess (nil) automatically create and check out
|
|
100
|
+
# a local branch from a uniquely matching remote-tracking branch
|
|
101
|
+
# (`--guess`)
|
|
102
|
+
#
|
|
103
|
+
# @option options [Boolean, nil] :no_guess (nil) disable automatic remote branch
|
|
104
|
+
# matching (`--no-guess`)
|
|
105
|
+
#
|
|
106
|
+
# @option options [Boolean, nil] :l (nil) create the new branch's reflog
|
|
107
|
+
#
|
|
108
|
+
# @option options [Boolean, nil] :detach (nil) detach HEAD at the specified
|
|
109
|
+
# commit rather than pointing a branch at it
|
|
110
|
+
#
|
|
111
|
+
# Alias: `:d`
|
|
112
|
+
#
|
|
113
|
+
# @option options [String] :orphan (nil) create a new unborn branch with no
|
|
114
|
+
# history; the positional `branch` argument becomes the start point
|
|
115
|
+
#
|
|
116
|
+
# @option options [Boolean, nil] :merge (nil) perform a three-way merge when
|
|
117
|
+
# local modifications conflict with the target branch
|
|
118
|
+
#
|
|
119
|
+
# Alias: `:m`
|
|
120
|
+
#
|
|
121
|
+
# @option options [Boolean, nil] :ignore_other_worktrees (nil) check out the
|
|
122
|
+
# branch even if it is already in use by another worktree
|
|
123
|
+
#
|
|
124
|
+
# @option options [Boolean, nil] :overwrite_ignore (nil) silently overwrite
|
|
125
|
+
# ignored files when switching branches (`--overwrite-ignore`)
|
|
126
|
+
#
|
|
127
|
+
# @option options [Boolean, nil] :no_overwrite_ignore (nil) abort the checkout
|
|
128
|
+
# if ignored files would be overwritten (`--no-overwrite-ignore`)
|
|
129
|
+
#
|
|
130
|
+
# @option options [Boolean, nil] :recurse_submodules (nil) update all active
|
|
131
|
+
# submodule working trees to match the new branch
|
|
132
|
+
# (`--recurse-submodules`)
|
|
133
|
+
#
|
|
134
|
+
# @option options [Boolean, nil] :no_recurse_submodules (nil) do not update
|
|
135
|
+
# submodule working trees when switching branches
|
|
136
|
+
# (`--no-recurse-submodules`)
|
|
137
|
+
#
|
|
138
|
+
# @option options [String] :chdir (nil) change to this directory before
|
|
139
|
+
# running git; not passed to the git CLI
|
|
140
|
+
#
|
|
141
|
+
# @return [Git::CommandLineResult] the result of calling `git checkout`
|
|
142
|
+
#
|
|
143
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
144
|
+
#
|
|
145
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
146
|
+
#
|
|
147
|
+
# @api public
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module Checkout
|
|
8
|
+
# Implements the `git checkout` command for restoring working tree files
|
|
9
|
+
#
|
|
10
|
+
# This command replaces files in the working tree with versions from
|
|
11
|
+
# the index (when tree_ish is nil) or a specified tree-ish (commit,
|
|
12
|
+
# branch, tag, etc.).
|
|
13
|
+
#
|
|
14
|
+
# @example Restore working tree files
|
|
15
|
+
# files = Git::Commands::Checkout::Files.new(execution_context)
|
|
16
|
+
# files.call(pathspec: ['lib/foo.rb']) # from the index
|
|
17
|
+
# files.call('HEAD~1', pathspec: ['lib/foo.rb']) # from a specific commit
|
|
18
|
+
# files.call('main', pathspec: %w[lib/foo.rb lib/bar.rb]) # from a branch
|
|
19
|
+
# files.call(pathspec: ['conflicted.txt'], ours: true) # resolve conflict (ours)
|
|
20
|
+
# files.call('main', pathspec_from_file: 'paths.txt') # paths from a file
|
|
21
|
+
#
|
|
22
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-checkout/2.53.0
|
|
23
|
+
#
|
|
24
|
+
# @see Git::Commands::Checkout
|
|
25
|
+
#
|
|
26
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
#
|
|
30
|
+
class Files < Git::Commands::Base
|
|
31
|
+
arguments do
|
|
32
|
+
literal 'checkout'
|
|
33
|
+
flag_option %i[force f]
|
|
34
|
+
flag_option :ours
|
|
35
|
+
flag_option :theirs
|
|
36
|
+
flag_option %i[merge m]
|
|
37
|
+
value_option :conflict, inline: true
|
|
38
|
+
flag_option :overlay, negatable: true
|
|
39
|
+
flag_option :ignore_skip_worktree_bits
|
|
40
|
+
value_option :pathspec_from_file, inline: true
|
|
41
|
+
flag_option :pathspec_file_nul
|
|
42
|
+
|
|
43
|
+
execution_option :chdir
|
|
44
|
+
|
|
45
|
+
operand :tree_ish
|
|
46
|
+
end_of_options
|
|
47
|
+
value_option :pathspec, as_operand: true, repeatable: true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @!method call(*, **)
|
|
51
|
+
#
|
|
52
|
+
# @overload call(tree_ish = nil, **options)
|
|
53
|
+
#
|
|
54
|
+
# Execute the git checkout command for restoring files
|
|
55
|
+
#
|
|
56
|
+
# @param tree_ish [String, nil] The commit, branch, or tree to restore
|
|
57
|
+
# files from
|
|
58
|
+
#
|
|
59
|
+
# When `nil`, files are restored from the index
|
|
60
|
+
#
|
|
61
|
+
# @param options [Hash] command options
|
|
62
|
+
#
|
|
63
|
+
# @option options [Boolean, nil] :force (nil) ignore unmerged entries
|
|
64
|
+
#
|
|
65
|
+
# Alias: `:f`
|
|
66
|
+
#
|
|
67
|
+
# @option options [Boolean, nil] :ours (nil) for unmerged paths, check out
|
|
68
|
+
# stage #2 (our version)
|
|
69
|
+
#
|
|
70
|
+
# @option options [Boolean, nil] :theirs (nil) for unmerged paths, check out
|
|
71
|
+
# stage #3 (their version)
|
|
72
|
+
#
|
|
73
|
+
# @option options [Boolean, nil] :merge (nil) recreate the conflicted merge in
|
|
74
|
+
# the specified paths; cannot be used when checking out from a tree-ish
|
|
75
|
+
#
|
|
76
|
+
# Alias: `:m`
|
|
77
|
+
#
|
|
78
|
+
# @option options [String] :conflict (nil) conflict marker style; valid
|
|
79
|
+
# values are `'merge'`, `'diff3'`, and `'zdiff3'`
|
|
80
|
+
#
|
|
81
|
+
# @option options [Boolean, nil] :overlay (nil) never remove files from the
|
|
82
|
+
# index or working tree that are not present in the tree-ish (`--overlay`)
|
|
83
|
+
#
|
|
84
|
+
# @option options [Boolean, nil] :no_overlay (nil) remove files not present
|
|
85
|
+
# in the tree-ish from the index and working tree (`--no-overlay`)
|
|
86
|
+
#
|
|
87
|
+
# @option options [Boolean, nil] :ignore_skip_worktree_bits (nil) in sparse
|
|
88
|
+
# checkout mode, ignore sparse patterns and update all files matched by
|
|
89
|
+
# pathspec
|
|
90
|
+
#
|
|
91
|
+
# @option options [String] :pathspec_from_file (nil) read pathspec from
|
|
92
|
+
# this file; pass `'-'` to read from stdin
|
|
93
|
+
#
|
|
94
|
+
# @option options [Boolean, nil] :pathspec_file_nul (nil) with
|
|
95
|
+
# `:pathspec_from_file`, separate pathspec elements with NUL instead of
|
|
96
|
+
# newline
|
|
97
|
+
#
|
|
98
|
+
# @option options [Array<String>, String] :pathspec (nil) the files or
|
|
99
|
+
# directories to restore
|
|
100
|
+
#
|
|
101
|
+
# @option options [String] :chdir (nil) change to this directory before
|
|
102
|
+
# running git; not passed to the git CLI
|
|
103
|
+
#
|
|
104
|
+
# @return [Git::CommandLineResult] the result of calling `git checkout`
|
|
105
|
+
#
|
|
106
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
107
|
+
#
|
|
108
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
109
|
+
#
|
|
110
|
+
# @api public
|
|
111
|
+
#
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'checkout/branch'
|
|
4
|
+
require_relative 'checkout/files'
|
|
5
|
+
|
|
6
|
+
module Git
|
|
7
|
+
module Commands
|
|
8
|
+
# Commands for switching branches and restoring files via `git checkout`
|
|
9
|
+
#
|
|
10
|
+
# This module contains command classes split by checkout mode:
|
|
11
|
+
#
|
|
12
|
+
# - {Checkout::Branch} — switch branches or create and switch to a new branch
|
|
13
|
+
# - {Checkout::Files} — restore working tree files from a given tree-ish
|
|
14
|
+
#
|
|
15
|
+
# @api private
|
|
16
|
+
#
|
|
17
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout documentation
|
|
18
|
+
#
|
|
19
|
+
# @example Switch to an existing branch
|
|
20
|
+
# cmd = Git::Commands::Checkout::Branch.new(lib)
|
|
21
|
+
# cmd.call('main')
|
|
22
|
+
#
|
|
23
|
+
# @example Create and switch to a new branch
|
|
24
|
+
# cmd = Git::Commands::Checkout::Branch.new(lib)
|
|
25
|
+
# cmd.call('main', b: 'feature/new-feature')
|
|
26
|
+
#
|
|
27
|
+
# @example Restore a file from the index (discard uncommitted changes)
|
|
28
|
+
# cmd = Git::Commands::Checkout::Files.new(lib)
|
|
29
|
+
# cmd.call(pathspec: ['lib/my_file.rb'])
|
|
30
|
+
#
|
|
31
|
+
# @example Restore a file from a specific branch
|
|
32
|
+
# cmd = Git::Commands::Checkout::Files.new(lib)
|
|
33
|
+
# cmd.call('main', pathspec: ['lib/my_file.rb'])
|
|
34
|
+
#
|
|
35
|
+
module Checkout
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git checkout-index` command
|
|
8
|
+
#
|
|
9
|
+
# This command copies all files listed in the index to the working directory
|
|
10
|
+
# (not overwriting existing files). It is typically used to populate a new
|
|
11
|
+
# working directory from the current index, optionally scoped to a specific
|
|
12
|
+
# path or prefix.
|
|
13
|
+
#
|
|
14
|
+
# @example Typical usage
|
|
15
|
+
# checkout_index = Git::Commands::CheckoutIndex.new(execution_context)
|
|
16
|
+
# checkout_index.call(all: true)
|
|
17
|
+
# checkout_index.call(all: true, force: true)
|
|
18
|
+
# checkout_index.call('path/to/file.txt')
|
|
19
|
+
# checkout_index.call(all: true, prefix: 'output/')
|
|
20
|
+
#
|
|
21
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-checkout-index/2.53.0
|
|
22
|
+
#
|
|
23
|
+
# @see https://git-scm.com/docs/git-checkout-index git-checkout-index
|
|
24
|
+
#
|
|
25
|
+
# @see Git::Commands
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
class CheckoutIndex < Git::Commands::Base
|
|
30
|
+
arguments do
|
|
31
|
+
literal 'checkout-index'
|
|
32
|
+
flag_option %i[index u]
|
|
33
|
+
flag_option %i[quiet q]
|
|
34
|
+
flag_option %i[all a]
|
|
35
|
+
flag_option %i[force f]
|
|
36
|
+
flag_option %i[no_create n]
|
|
37
|
+
value_option :prefix, inline: true
|
|
38
|
+
value_option :stage, inline: true
|
|
39
|
+
flag_option :temp
|
|
40
|
+
flag_option :ignore_skip_worktree_bits
|
|
41
|
+
end_of_options
|
|
42
|
+
operand :file, required: false, repeatable: true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @!method call(*, **)
|
|
46
|
+
#
|
|
47
|
+
# @overload call(*file, **options)
|
|
48
|
+
#
|
|
49
|
+
# Execute the `git checkout-index` command
|
|
50
|
+
#
|
|
51
|
+
# @param file [Array<String>] zero or more file paths to check out
|
|
52
|
+
#
|
|
53
|
+
# When empty, no files are checked out individually (use `:all` to check
|
|
54
|
+
# out everything).
|
|
55
|
+
#
|
|
56
|
+
# @param options [Hash] command options
|
|
57
|
+
#
|
|
58
|
+
# @option options [Boolean, nil] :index (nil) update stat information for the
|
|
59
|
+
# checked out entries in the index file
|
|
60
|
+
#
|
|
61
|
+
# Alias: `:u`
|
|
62
|
+
#
|
|
63
|
+
# @option options [Boolean, nil] :quiet (nil) suppress messages when files
|
|
64
|
+
# exist or are not in the index
|
|
65
|
+
#
|
|
66
|
+
# Alias: `:q`
|
|
67
|
+
#
|
|
68
|
+
# @option options [Boolean, nil] :all (nil) check out all files in the index
|
|
69
|
+
#
|
|
70
|
+
# Alias: `:a`
|
|
71
|
+
#
|
|
72
|
+
# @option options [Boolean, nil] :force (nil) force overwrite of existing files
|
|
73
|
+
#
|
|
74
|
+
# Alias: `:f`
|
|
75
|
+
#
|
|
76
|
+
# @option options [Boolean, nil] :no_create (nil) don't checkout new files,
|
|
77
|
+
# only refresh files already checked out
|
|
78
|
+
#
|
|
79
|
+
# Alias: `:n`
|
|
80
|
+
#
|
|
81
|
+
# @option options [String] :prefix (nil) write file content under the given
|
|
82
|
+
# directory prefix instead of the working directory root
|
|
83
|
+
#
|
|
84
|
+
# @option options [String] :stage (nil) check out from the named stage
|
|
85
|
+
#
|
|
86
|
+
# Pass `'1'`, `'2'`, or `'3'` for a specific stage number, or `'all'` to
|
|
87
|
+
# check out all stages (automatically implies `--temp`).
|
|
88
|
+
#
|
|
89
|
+
# @option options [Boolean, nil] :temp (nil) write file content to temporary
|
|
90
|
+
# files near the target location instead of checking them out
|
|
91
|
+
#
|
|
92
|
+
# @option options [Boolean, nil] :ignore_skip_worktree_bits (nil) check out
|
|
93
|
+
# all files, including those with the skip-worktree bit set
|
|
94
|
+
#
|
|
95
|
+
# @return [Git::CommandLineResult] the result of calling `git checkout-index`
|
|
96
|
+
#
|
|
97
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
98
|
+
#
|
|
99
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
100
|
+
#
|
|
101
|
+
# @api public
|
|
102
|
+
#
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Remove untracked files from the working tree
|
|
8
|
+
#
|
|
9
|
+
# Cleans the working tree by recursively removing files that are not under
|
|
10
|
+
# version control. Only files unknown to Git are removed by default; with
|
|
11
|
+
# `:x` also removes ignored files; with `:X` removes only ignored files.
|
|
12
|
+
#
|
|
13
|
+
# @example Typical usage
|
|
14
|
+
# clean = Git::Commands::Clean.new(execution_context)
|
|
15
|
+
# clean.call(force: true)
|
|
16
|
+
# clean.call(force: true, d: true)
|
|
17
|
+
# clean.call(force: 2)
|
|
18
|
+
# clean.call(dry_run: true)
|
|
19
|
+
# clean.call(force: true, exclude: '*.log')
|
|
20
|
+
# clean.call(force: true, X: true)
|
|
21
|
+
# clean.call(force: true, pathspec: ['tmp/', 'build/'])
|
|
22
|
+
#
|
|
23
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-clean/2.53.0
|
|
24
|
+
#
|
|
25
|
+
# @see Git::Commands
|
|
26
|
+
#
|
|
27
|
+
# @see https://git-scm.com/docs/git-clean git-clean
|
|
28
|
+
#
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
class Clean < Git::Commands::Base
|
|
32
|
+
arguments do
|
|
33
|
+
literal 'clean'
|
|
34
|
+
flag_option :d
|
|
35
|
+
flag_option %i[force f], max_times: 2
|
|
36
|
+
flag_option %i[dry_run n]
|
|
37
|
+
flag_option %i[quiet q]
|
|
38
|
+
value_option %i[exclude e], inline: true, repeatable: true
|
|
39
|
+
flag_option :x
|
|
40
|
+
flag_option :X
|
|
41
|
+
execution_option :chdir
|
|
42
|
+
end_of_options
|
|
43
|
+
value_option :pathspec, as_operand: true, repeatable: true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @!method call(*, **)
|
|
47
|
+
#
|
|
48
|
+
# @overload call(**options)
|
|
49
|
+
#
|
|
50
|
+
# Execute the git clean command
|
|
51
|
+
#
|
|
52
|
+
# @param options [Hash] command options
|
|
53
|
+
#
|
|
54
|
+
# @option options [Boolean, nil] :d (nil) recurse into untracked directories
|
|
55
|
+
#
|
|
56
|
+
# @option options [Boolean, Integer, nil] :force (nil) force the removal of untracked files
|
|
57
|
+
#
|
|
58
|
+
# When `clean.requireForce` is not set to `false`, git-clean will refuse to
|
|
59
|
+
# delete files or directories unless this option is given.
|
|
60
|
+
#
|
|
61
|
+
# Pass `true` or `1` to emit `--force` once. Pass `2` to emit `--force --force`,
|
|
62
|
+
# which also removes untracked nested git repositories (directories with a
|
|
63
|
+
# `.git` subdirectory).
|
|
64
|
+
#
|
|
65
|
+
# Alias: `:f`
|
|
66
|
+
#
|
|
67
|
+
# @option options [Boolean, nil] :dry_run (nil) don't actually remove anything, just
|
|
68
|
+
# show what would be done
|
|
69
|
+
#
|
|
70
|
+
# Alias: `:n`
|
|
71
|
+
#
|
|
72
|
+
# @option options [Boolean, nil] :quiet (nil) be quiet, only report errors
|
|
73
|
+
#
|
|
74
|
+
# Alias: `:q`
|
|
75
|
+
#
|
|
76
|
+
# @option options [String, Array<String>] :exclude (nil) use the given exclude
|
|
77
|
+
# pattern in addition to the standard ignore rules
|
|
78
|
+
#
|
|
79
|
+
# May be specified multiple times. Alias: `:e`
|
|
80
|
+
#
|
|
81
|
+
# @option options [Boolean, nil] :x (nil) don't use the standard ignore rules
|
|
82
|
+
#
|
|
83
|
+
# @option options [Boolean, nil] :X (nil) remove only files ignored by Git
|
|
84
|
+
#
|
|
85
|
+
# @option options [String, Array<String>] :pathspec (nil) limit cleaning to files
|
|
86
|
+
# matching the given pathspec(s)
|
|
87
|
+
#
|
|
88
|
+
# @option options [String, nil] :chdir (nil) change to this directory before
|
|
89
|
+
# running git; not passed to the git CLI
|
|
90
|
+
#
|
|
91
|
+
# @return [Git::CommandLineResult] the result of calling `git clean`
|
|
92
|
+
#
|
|
93
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
94
|
+
#
|
|
95
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
96
|
+
#
|
|
97
|
+
# @api public
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|