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,338 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git grep` command
|
|
8
|
+
#
|
|
9
|
+
# Searches for a pattern in the contents of tracked files within a repository
|
|
10
|
+
# tree.
|
|
11
|
+
#
|
|
12
|
+
# @example Typical usage
|
|
13
|
+
# grep = Git::Commands::Grep.new(execution_context)
|
|
14
|
+
# grep.call('HEAD', pattern: 'search')
|
|
15
|
+
# grep.call('HEAD', pattern: 'SEARCH', ignore_case: true)
|
|
16
|
+
# grep.call('HEAD', pattern: 'search', invert_match: true)
|
|
17
|
+
# grep.call('HEAD', pattern: 'foo|bar', extended_regexp: true)
|
|
18
|
+
# grep.call('HEAD', pattern: 'search', pathspec: 'lib/**')
|
|
19
|
+
#
|
|
20
|
+
# @note `arguments` block audited against
|
|
21
|
+
# https://git-scm.com/docs/git-grep/2.53.0
|
|
22
|
+
#
|
|
23
|
+
# @see https://git-scm.com/docs/git-grep git-grep
|
|
24
|
+
#
|
|
25
|
+
# @see Git::Commands
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
class Grep < Git::Commands::Base
|
|
30
|
+
arguments do
|
|
31
|
+
literal 'grep'
|
|
32
|
+
|
|
33
|
+
# Encoding and binary handling
|
|
34
|
+
flag_option %i[text a]
|
|
35
|
+
flag_option :I
|
|
36
|
+
flag_option :textconv, negatable: true
|
|
37
|
+
|
|
38
|
+
# Pattern matching
|
|
39
|
+
flag_option %i[ignore_case i]
|
|
40
|
+
flag_option %i[word_regexp w]
|
|
41
|
+
flag_option %i[invert_match v]
|
|
42
|
+
flag_option :h
|
|
43
|
+
flag_option :H
|
|
44
|
+
flag_option :full_name
|
|
45
|
+
|
|
46
|
+
# Regexp flavour
|
|
47
|
+
flag_option %i[extended_regexp E]
|
|
48
|
+
flag_option %i[basic_regexp G]
|
|
49
|
+
flag_option %i[perl_regexp P]
|
|
50
|
+
flag_option %i[fixed_strings F]
|
|
51
|
+
|
|
52
|
+
# Output format
|
|
53
|
+
flag_option %i[line_number n]
|
|
54
|
+
flag_option :column
|
|
55
|
+
flag_option %i[files_with_matches name_only l]
|
|
56
|
+
flag_option %i[files_without_match L]
|
|
57
|
+
flag_option %i[null z]
|
|
58
|
+
flag_option %i[only_matching o]
|
|
59
|
+
flag_option %i[count c]
|
|
60
|
+
flag_option :all_match
|
|
61
|
+
flag_option %i[quiet q]
|
|
62
|
+
|
|
63
|
+
# Depth and recursion
|
|
64
|
+
value_option :max_depth
|
|
65
|
+
flag_option %i[recursive r], negatable: true
|
|
66
|
+
|
|
67
|
+
# Color
|
|
68
|
+
flag_or_value_option :color, inline: true
|
|
69
|
+
flag_option :no_color
|
|
70
|
+
|
|
71
|
+
# Display
|
|
72
|
+
flag_option :break
|
|
73
|
+
flag_option :heading
|
|
74
|
+
flag_option %i[show_function p]
|
|
75
|
+
|
|
76
|
+
# Context lines
|
|
77
|
+
value_option %i[after_context A], inline: true
|
|
78
|
+
value_option %i[before_context B], inline: true
|
|
79
|
+
value_option %i[context C], inline: true
|
|
80
|
+
flag_option %i[function_context W]
|
|
81
|
+
|
|
82
|
+
# Limits and performance
|
|
83
|
+
value_option %i[max_count m]
|
|
84
|
+
value_option :threads
|
|
85
|
+
|
|
86
|
+
# Pattern input
|
|
87
|
+
value_option :f, repeatable: true
|
|
88
|
+
|
|
89
|
+
# Accepts a String (simple pattern) or an Array (raw CLI args passthrough
|
|
90
|
+
# for compound boolean expressions like ['-e', 'foo', '--and', '-e', 'bar']).
|
|
91
|
+
custom_option :pattern, required: true, allow_nil: false do |value|
|
|
92
|
+
case value
|
|
93
|
+
when String then ['-e', value]
|
|
94
|
+
when Array then value
|
|
95
|
+
else raise ArgumentError, ":pattern must be a String or Array, got #{value.class}"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Source selection
|
|
100
|
+
flag_option :recurse_submodules
|
|
101
|
+
value_option :parent_basename
|
|
102
|
+
flag_option :exclude_standard, negatable: true
|
|
103
|
+
flag_option :cached
|
|
104
|
+
flag_option :untracked
|
|
105
|
+
flag_option :no_index
|
|
106
|
+
|
|
107
|
+
operand :tree, repeatable: true
|
|
108
|
+
end_of_options
|
|
109
|
+
value_option :pathspec, as_operand: true, repeatable: true
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# `git grep` exits with 1 when no lines are selected — not an error
|
|
113
|
+
allow_exit_status 0..1
|
|
114
|
+
|
|
115
|
+
# @!method call(*, **)
|
|
116
|
+
#
|
|
117
|
+
# @overload call(*tree, **options)
|
|
118
|
+
#
|
|
119
|
+
# Execute the `git grep` command
|
|
120
|
+
#
|
|
121
|
+
# @param tree [Array<String>] zero or more tree-ish references to search
|
|
122
|
+
# (e.g. commit SHAs, tags, or branch names); when omitted, git
|
|
123
|
+
# searches the working tree
|
|
124
|
+
#
|
|
125
|
+
# @param options [Hash] command options
|
|
126
|
+
#
|
|
127
|
+
# @option options [Boolean, nil] :text (nil) process binary files as if they
|
|
128
|
+
# were text
|
|
129
|
+
#
|
|
130
|
+
# Alias: :a
|
|
131
|
+
#
|
|
132
|
+
# @option options [Boolean, nil] :I (nil) do not match the pattern in binary
|
|
133
|
+
# files
|
|
134
|
+
#
|
|
135
|
+
# @option options [Boolean, nil] :textconv (nil) honor textconv filter
|
|
136
|
+
# settings (`--textconv`)
|
|
137
|
+
#
|
|
138
|
+
# @option options [Boolean, nil] :no_textconv (nil) suppress textconv filter
|
|
139
|
+
# processing (`--no-textconv`)
|
|
140
|
+
#
|
|
141
|
+
# @option options [Boolean, nil] :ignore_case (nil) ignore case distinctions
|
|
142
|
+
# in both the pattern and the file contents
|
|
143
|
+
#
|
|
144
|
+
# Alias: :i
|
|
145
|
+
#
|
|
146
|
+
# @option options [Boolean, nil] :word_regexp (nil) match the pattern only at
|
|
147
|
+
# word boundary
|
|
148
|
+
#
|
|
149
|
+
# Alias: :w
|
|
150
|
+
#
|
|
151
|
+
# @option options [Boolean, nil] :invert_match (nil) select non-matching lines
|
|
152
|
+
#
|
|
153
|
+
# Alias: :v
|
|
154
|
+
#
|
|
155
|
+
# @option options [Boolean, nil] :h (nil) suppress the filename prefix for
|
|
156
|
+
# each match
|
|
157
|
+
#
|
|
158
|
+
# @option options [Boolean, nil] :H (nil) print the filename for each match;
|
|
159
|
+
# overrides `:h` given earlier
|
|
160
|
+
#
|
|
161
|
+
# @option options [Boolean, nil] :full_name (nil) output paths relative to
|
|
162
|
+
# the project top directory rather than the current directory
|
|
163
|
+
#
|
|
164
|
+
# @option options [Boolean, nil] :extended_regexp (nil) use POSIX extended
|
|
165
|
+
# regular expressions for the pattern
|
|
166
|
+
#
|
|
167
|
+
# Alias: :E
|
|
168
|
+
#
|
|
169
|
+
# @option options [Boolean, nil] :basic_regexp (nil) use POSIX basic regular
|
|
170
|
+
# expressions for the pattern (the default regexp flavour)
|
|
171
|
+
#
|
|
172
|
+
# Alias: :G
|
|
173
|
+
#
|
|
174
|
+
# @option options [Boolean, nil] :perl_regexp (nil) use Perl-compatible
|
|
175
|
+
# regular expressions for the pattern
|
|
176
|
+
#
|
|
177
|
+
# Alias: :P
|
|
178
|
+
#
|
|
179
|
+
# @option options [Boolean, nil] :fixed_strings (nil) treat the pattern as a
|
|
180
|
+
# fixed string rather than a regular expression
|
|
181
|
+
#
|
|
182
|
+
# Alias: :F
|
|
183
|
+
#
|
|
184
|
+
# @option options [Boolean, nil] :line_number (nil) prefix each matching line
|
|
185
|
+
# with its line number within the file
|
|
186
|
+
#
|
|
187
|
+
# Alias: :n
|
|
188
|
+
#
|
|
189
|
+
# @option options [Boolean, nil] :column (nil) prefix the 1-indexed
|
|
190
|
+
# byte-offset of the first match from the start of the matching line
|
|
191
|
+
#
|
|
192
|
+
# @option options [Boolean, nil] :files_with_matches (nil) show only the
|
|
193
|
+
# names of files that contain matches, not the matching lines
|
|
194
|
+
#
|
|
195
|
+
# Aliases: :name_only, :l
|
|
196
|
+
#
|
|
197
|
+
# @option options [Boolean, nil] :files_without_match (nil) show only the
|
|
198
|
+
# names of files that do not contain matches
|
|
199
|
+
#
|
|
200
|
+
# Alias: :L
|
|
201
|
+
#
|
|
202
|
+
# @option options [Boolean, nil] :null (nil) use NUL as the delimiter for
|
|
203
|
+
# pathnames in the output, printing them verbatim
|
|
204
|
+
#
|
|
205
|
+
# Alias: :z
|
|
206
|
+
#
|
|
207
|
+
# @option options [Boolean, nil] :only_matching (nil) print only the matched
|
|
208
|
+
# (non-empty) parts of a matching line, each on a separate output line
|
|
209
|
+
#
|
|
210
|
+
# Alias: :o
|
|
211
|
+
#
|
|
212
|
+
# @option options [Boolean, nil] :count (nil) show the number of matching
|
|
213
|
+
# lines per file instead of the matching lines themselves
|
|
214
|
+
#
|
|
215
|
+
# Alias: :c
|
|
216
|
+
#
|
|
217
|
+
# @option options [Boolean, nil] :all_match (nil) when using multiple `--or`
|
|
218
|
+
# patterns, limit matches to files that have lines matching all of them
|
|
219
|
+
#
|
|
220
|
+
# @option options [Boolean, nil] :quiet (nil) do not output matching lines;
|
|
221
|
+
# exit 0 when there is a match and non-zero when there is not
|
|
222
|
+
#
|
|
223
|
+
# Alias: :q
|
|
224
|
+
#
|
|
225
|
+
# @option options [Integer, String] :max_depth (nil) descend at most this
|
|
226
|
+
# many directory levels for each pathspec argument
|
|
227
|
+
#
|
|
228
|
+
# @option options [Boolean, nil] :recursive (nil) recurse into subdirectories
|
|
229
|
+
# (same as `--max-depth=-1`; this is the default)
|
|
230
|
+
#
|
|
231
|
+
# Alias: :r
|
|
232
|
+
#
|
|
233
|
+
# @option options [Boolean, nil] :no_recursive (nil) do not recurse into
|
|
234
|
+
# subdirectories (`--no-recursive`, equivalent to `--max-depth=0`)
|
|
235
|
+
#
|
|
236
|
+
# @option options [Boolean, String, nil] :color (nil) show colored matches
|
|
237
|
+
#
|
|
238
|
+
# When `true`, emits bare `--color`. Pass a string to emit
|
|
239
|
+
# `--color=<when>` (values: `'always'`, `'never'`, `'auto'`).
|
|
240
|
+
#
|
|
241
|
+
# @option options [Boolean, nil] :no_color (nil) turn off match highlighting,
|
|
242
|
+
# even when the configuration file gives the default to color output
|
|
243
|
+
#
|
|
244
|
+
# @option options [Boolean, nil] :break (nil) print an empty line between
|
|
245
|
+
# matches from different files
|
|
246
|
+
#
|
|
247
|
+
# @option options [Boolean, nil] :heading (nil) show the filename above the
|
|
248
|
+
# matches in that file instead of at the start of each shown line
|
|
249
|
+
#
|
|
250
|
+
# @option options [Boolean, nil] :show_function (nil) show the nearest
|
|
251
|
+
# function name preceding each match
|
|
252
|
+
#
|
|
253
|
+
# Alias: :p
|
|
254
|
+
#
|
|
255
|
+
# @option options [Integer, String] :after_context (nil) show this many
|
|
256
|
+
# trailing lines after each match
|
|
257
|
+
#
|
|
258
|
+
# Alias: :A
|
|
259
|
+
#
|
|
260
|
+
# @option options [Integer, String] :before_context (nil) show this many
|
|
261
|
+
# leading lines before each match
|
|
262
|
+
#
|
|
263
|
+
# Alias: :B
|
|
264
|
+
#
|
|
265
|
+
# @option options [Integer, String] :context (nil) show this many leading
|
|
266
|
+
# and trailing lines around each match
|
|
267
|
+
#
|
|
268
|
+
# Alias: :C
|
|
269
|
+
#
|
|
270
|
+
# @option options [Boolean, nil] :function_context (nil) show the surrounding
|
|
271
|
+
# text from the previous function name up to the next
|
|
272
|
+
#
|
|
273
|
+
# Alias: :W
|
|
274
|
+
#
|
|
275
|
+
# @option options [Integer, String] :max_count (nil) limit the number of
|
|
276
|
+
# matches per file
|
|
277
|
+
#
|
|
278
|
+
# Alias: :m
|
|
279
|
+
#
|
|
280
|
+
# @option options [Integer, String] :threads (nil) number of grep worker
|
|
281
|
+
# threads to use
|
|
282
|
+
#
|
|
283
|
+
# @option options [String, Array<String>] :f (nil) read patterns from a
|
|
284
|
+
# file, one per line; may be passed as an Array to supply multiple
|
|
285
|
+
# pattern files
|
|
286
|
+
#
|
|
287
|
+
# @option options [String, Array<String>] :pattern (nil) the search
|
|
288
|
+
# pattern (required; must not be nil)
|
|
289
|
+
#
|
|
290
|
+
# Pass a String for a simple pattern (emitted as `-e <pattern>`).
|
|
291
|
+
# Pass an Array of raw CLI arguments for compound boolean
|
|
292
|
+
# expressions (e.g. `['-e', 'foo', '--and', '-e', 'bar']`).
|
|
293
|
+
#
|
|
294
|
+
# @option options [Boolean, nil] :recurse_submodules (nil) recursively search
|
|
295
|
+
# in each active, checked-out submodule
|
|
296
|
+
#
|
|
297
|
+
# @option options [String] :parent_basename (nil) override the name used
|
|
298
|
+
# as a prefix for submodule output when used with `:recurse_submodules`
|
|
299
|
+
#
|
|
300
|
+
# @option options [Boolean, nil] :exclude_standard (nil) honor the `.gitignore`
|
|
301
|
+
# mechanism when searching untracked files (`--exclude-standard`)
|
|
302
|
+
#
|
|
303
|
+
# @option options [Boolean, nil] :no_exclude_standard (nil) do not honor the
|
|
304
|
+
# `.gitignore` mechanism; also search ignored files
|
|
305
|
+
# (`--no-exclude-standard`); only useful with `:untracked` or `:no_index`
|
|
306
|
+
#
|
|
307
|
+
# @option options [Boolean, nil] :cached (nil) search blobs registered in the
|
|
308
|
+
# index instead of tracked files in the working tree
|
|
309
|
+
#
|
|
310
|
+
# @option options [Boolean, nil] :untracked (nil) search untracked files in
|
|
311
|
+
# addition to tracked files in the working tree
|
|
312
|
+
#
|
|
313
|
+
# @option options [Boolean, nil] :no_index (nil) search files in the current
|
|
314
|
+
# directory without regard to whether it is managed by Git
|
|
315
|
+
#
|
|
316
|
+
# @option options [String, Array<String>] :pathspec (nil) limit the
|
|
317
|
+
# search to files matching the given pathspec(s)
|
|
318
|
+
#
|
|
319
|
+
# Multiple pathspecs may be passed as an Array. Appended to the
|
|
320
|
+
# command after `--`.
|
|
321
|
+
#
|
|
322
|
+
# @return [Git::CommandLineResult] the result of calling `git grep`
|
|
323
|
+
#
|
|
324
|
+
# Exit status 0 means matches were found; exit status 1 means no
|
|
325
|
+
# lines were selected (not an error).
|
|
326
|
+
#
|
|
327
|
+
# @raise [ArgumentError] if `:pattern` is missing or nil
|
|
328
|
+
#
|
|
329
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
330
|
+
#
|
|
331
|
+
# @raise [Git::FailedError] if git exits outside the allowed range
|
|
332
|
+
# (exit code > 1)
|
|
333
|
+
#
|
|
334
|
+
# @api public
|
|
335
|
+
#
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git init` command
|
|
8
|
+
#
|
|
9
|
+
# Create an empty Git repository or reinitialize an existing one.
|
|
10
|
+
#
|
|
11
|
+
# @example Typical usage
|
|
12
|
+
# init = Git::Commands::Init.new(execution_context)
|
|
13
|
+
# init.call
|
|
14
|
+
# init.call('my-repo')
|
|
15
|
+
# init.call('my-repo.git', bare: true)
|
|
16
|
+
# init.call('my-repo', initial_branch: 'main')
|
|
17
|
+
# init.call('my-repo', template: '/path/to/templates')
|
|
18
|
+
#
|
|
19
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-init/2.53.0
|
|
20
|
+
#
|
|
21
|
+
# @see https://git-scm.com/docs/git-init git-init
|
|
22
|
+
#
|
|
23
|
+
# @see Git::Commands
|
|
24
|
+
#
|
|
25
|
+
# @api private
|
|
26
|
+
#
|
|
27
|
+
class Init < Git::Commands::Base
|
|
28
|
+
arguments do
|
|
29
|
+
literal 'init'
|
|
30
|
+
flag_option %i[quiet q]
|
|
31
|
+
flag_option :bare
|
|
32
|
+
value_option :template, inline: true
|
|
33
|
+
value_option :separate_git_dir, inline: true
|
|
34
|
+
value_option :object_format, inline: true
|
|
35
|
+
value_option :ref_format, inline: true
|
|
36
|
+
value_option %i[initial_branch b], inline: true
|
|
37
|
+
flag_or_value_option :shared, inline: true
|
|
38
|
+
|
|
39
|
+
end_of_options
|
|
40
|
+
operand :directory
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @!method call(*, **)
|
|
44
|
+
#
|
|
45
|
+
# @overload call(directory = nil, **options)
|
|
46
|
+
#
|
|
47
|
+
# Execute the `git init` command
|
|
48
|
+
#
|
|
49
|
+
# @param directory [String, nil] path to the directory to initialize
|
|
50
|
+
#
|
|
51
|
+
# If `nil` or omitted, initializes the repository in the current
|
|
52
|
+
# directory (`.`).
|
|
53
|
+
#
|
|
54
|
+
# If `:bare` is false, initializes `.git` inside this directory. If
|
|
55
|
+
# `:bare` is true, creates the bare repository directly in this directory.
|
|
56
|
+
#
|
|
57
|
+
# @param options [Hash] command options
|
|
58
|
+
#
|
|
59
|
+
# @option options [Boolean, nil] :quiet (nil) suppress all output except errors
|
|
60
|
+
# and warnings
|
|
61
|
+
#
|
|
62
|
+
# Alias: `:q`
|
|
63
|
+
#
|
|
64
|
+
# @option options [Boolean, nil] :bare (nil) create a bare repository
|
|
65
|
+
#
|
|
66
|
+
# @option options [String] :template (nil) path to the directory from which
|
|
67
|
+
# templates will be used
|
|
68
|
+
#
|
|
69
|
+
# @option options [String] :separate_git_dir (nil) path at which to create
|
|
70
|
+
# the repository; writes a gitfile at the working-tree root pointing to it
|
|
71
|
+
#
|
|
72
|
+
# @option options [String] :object_format (nil) hash algorithm for the
|
|
73
|
+
# repository (`sha1` or `sha256`)
|
|
74
|
+
#
|
|
75
|
+
# @option options [String] :ref_format (nil) ref storage format for the
|
|
76
|
+
# repository (`files` or `reftable`)
|
|
77
|
+
#
|
|
78
|
+
# @option options [String] :initial_branch (nil) name to use for the initial
|
|
79
|
+
# branch in the newly created repository
|
|
80
|
+
#
|
|
81
|
+
# Alias: `:b`
|
|
82
|
+
#
|
|
83
|
+
# @option options [Boolean, String, nil] :shared (nil) configure the repository
|
|
84
|
+
# to be shared among multiple users
|
|
85
|
+
#
|
|
86
|
+
# Pass `true` to emit `--shared` (which defaults to `group` permissions).
|
|
87
|
+
# Pass a string (e.g. `'group'`, `'all'`, `'0660'`) to emit
|
|
88
|
+
# `--shared=<permissions>`.
|
|
89
|
+
#
|
|
90
|
+
# @return [Git::CommandLineResult] the result of calling `git init`
|
|
91
|
+
#
|
|
92
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
93
|
+
#
|
|
94
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
95
|
+
#
|
|
96
|
+
# @api public
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|