git 4.3.2 → 5.0.0.beta.2
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 +73 -2705
- data/.github/prompts/iteratively-address-copilot-reviews.prompt.md +188 -0
- 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/KEYWORD_ARG_REMEDIATION.md +22 -0
- data/.github/skills/extract-facade-from-base-lib/SKILL.md +600 -0
- data/.github/skills/facade-implementation/REFERENCE.md +840 -0
- data/.github/skills/facade-implementation/SKILL.md +274 -0
- data/.github/skills/facade-test-conventions/SKILL.md +394 -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 +12 -3
- data/.rubocop_todo.yml +23 -5
- data/.yardopts +1 -0
- data/CHANGELOG.md +0 -40
- data/CONTRIBUTING.md +694 -53
- data/README.md +67 -15
- data/Rakefile +61 -9
- data/UPGRADING.md +141 -0
- data/commitlint.test +4 -0
- data/git.gemspec +18 -7
- data/lib/git/args_builder.rb +0 -8
- data/lib/git/branch.rb +369 -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 +122 -24
- data/lib/git/command_line/base.rb +255 -0
- data/lib/git/command_line/capturing.rb +251 -0
- data/lib/git/command_line/result.rb +96 -0
- data/lib/git/command_line/streaming.rb +196 -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 +404 -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 +369 -0
- data/lib/git/commands/cat_file/filtered.rb +105 -0
- data/lib/git/commands/cat_file/raw.rb +216 -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 +107 -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 +57 -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 +87 -0
- data/lib/git/config.rb +17 -0
- data/lib/git/config_entry_info.rb +106 -0
- data/lib/git/configuring.rb +665 -0
- data/lib/git/deprecation.rb +9 -0
- data/lib/git/detached_head_info.rb +54 -0
- data/lib/git/diff.rb +293 -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 +67 -19
- data/lib/git/diff_result.rb +32 -0
- data/lib/git/diff_stats.rb +51 -14
- data/lib/git/dirstat_info.rb +86 -0
- data/lib/git/errors.rb +65 -2
- data/lib/git/execution_context/global.rb +31 -0
- data/lib/git/execution_context/repository.rb +136 -0
- data/lib/git/execution_context.rb +501 -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/log.rb +9 -2
- data/lib/git/object.rb +90 -27
- data/lib/git/parsers/branch.rb +224 -0
- data/lib/git/parsers/cat_file.rb +111 -0
- data/lib/git/parsers/config_entry.rb +110 -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_remote.rb +79 -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 +120 -9
- data/lib/git/repository/branching.rb +743 -0
- data/lib/git/repository/committing.rb +187 -0
- data/lib/git/repository/configuring.rb +351 -0
- data/lib/git/repository/context_helpers.rb +264 -0
- data/lib/git/repository/diffing.rb +775 -0
- data/lib/git/repository/factories.rb +682 -0
- data/lib/git/repository/inspecting.rb +252 -0
- data/lib/git/repository/logging.rb +247 -0
- data/lib/git/repository/maintenance.rb +65 -0
- data/lib/git/repository/merging.rb +357 -0
- data/lib/git/repository/object_operations.rb +1199 -0
- data/lib/git/repository/path_resolver.rb +207 -0
- data/lib/git/repository/remote_operations.rb +898 -0
- data/lib/git/repository/shared_private.rb +51 -0
- data/lib/git/repository/staging.rb +554 -0
- data/lib/git/repository/stashing.rb +143 -0
- data/lib/git/repository/status_operations.rb +201 -0
- data/lib/git/repository/worktree_operations.rb +159 -0
- data/lib/git/repository.rb +203 -1
- data/lib/git/stash.rb +78 -4
- data/lib/git/stash_info.rb +104 -0
- data/lib/git/stashes.rb +125 -13
- data/lib/git/status.rb +215 -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 +108 -6
- data/lib/git/worktrees.rb +94 -7
- data/lib/git.rb +260 -61
- data/redesign/1_architecture_existing.md +54 -18
- data/redesign/2_architecture_redesign.md +365 -46
- data/redesign/3_architecture_implementation.md +1497 -63
- data/redesign/Phase 4 - Step A.md +360 -0
- data/redesign/beta_release.md +107 -0
- data/redesign/c1c2_audit.md +566 -0
- data/redesign/c1c2_bucket6_lib_orphans.md +626 -0
- data/redesign/config_design.rb +501 -0
- 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 +365 -22
- data/lib/git/base.rb +0 -1128
- data/lib/git/index.rb +0 -6
- data/lib/git/lib.rb +0 -2277
- 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,501 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This is a forward looking document (in Ruby format) on the evolution of `git
|
|
4
|
+
# config` methods in Ruby Git. Here is how `git config` methods will change in
|
|
5
|
+
# v5.x and v6.x.
|
|
6
|
+
#
|
|
7
|
+
# In v5.x, `Git.config` and `Git.global_config` will continue to work as they do in
|
|
8
|
+
# v4.x but will be deprecated. New methods in the Git::Configuring module will be
|
|
9
|
+
# introduced in Git and Git::Repository to provide structured access to configuration
|
|
10
|
+
# entries. These will not be strict drop-in replacements for the existing deprecated
|
|
11
|
+
# methods.
|
|
12
|
+
#
|
|
13
|
+
# In v6.x, the deprecated methods will be removed.
|
|
14
|
+
|
|
15
|
+
# Top level Git module
|
|
16
|
+
module Git
|
|
17
|
+
# Represents a single Git configuration entry
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# scope = 'local'
|
|
21
|
+
# origin = 'path/to/config'
|
|
22
|
+
# key = 'remote.origin.url'
|
|
23
|
+
# value = 'https://github.com/ruby-git/ruby-git'
|
|
24
|
+
# entry = Git::ConfigEntryInfo.new(scope:, origin:, key: , value:)
|
|
25
|
+
#
|
|
26
|
+
# @!attribute [r] scope
|
|
27
|
+
#
|
|
28
|
+
# The scope of the configuration entry
|
|
29
|
+
#
|
|
30
|
+
# May be one of "system", "global", "local", "worktree", "file", or "blob".
|
|
31
|
+
#
|
|
32
|
+
# @return [String]
|
|
33
|
+
#
|
|
34
|
+
# @!attribute [r] origin
|
|
35
|
+
#
|
|
36
|
+
# Where the configuration entry originates
|
|
37
|
+
#
|
|
38
|
+
# The origin is in the format: `<origin-type>:<actual-origin>`. It is never
|
|
39
|
+
# blank.
|
|
40
|
+
#
|
|
41
|
+
# ### `origin-type`
|
|
42
|
+
#
|
|
43
|
+
# This prefix explains the context of the configuration source. The four possible
|
|
44
|
+
# types are `file:`, `blob:`, `command line:`, and `standard input:`.
|
|
45
|
+
#
|
|
46
|
+
# ### `actual-origin`
|
|
47
|
+
#
|
|
48
|
+
# This provides the specific location for the configuration source. Only the
|
|
49
|
+
# `file:` and `blob:` origin types have an actual origin. For `command line:` and
|
|
50
|
+
# `standard input:`, Git drops this portion entirely and places the tab character
|
|
51
|
+
# immediately after the colon.
|
|
52
|
+
#
|
|
53
|
+
# #### Path Resolution
|
|
54
|
+
#
|
|
55
|
+
# When the origin type is a file, the actual origin can be formatted as either an
|
|
56
|
+
# absolute or relative path depending on how Git resolves it.
|
|
57
|
+
#
|
|
58
|
+
# - **Absolute Paths**: Git outputs the full system path for system-level configurations,
|
|
59
|
+
# global configurations, explicitly provided absolute paths, or absolute
|
|
60
|
+
# paths used in [include] directives.
|
|
61
|
+
# - **Relative Paths**: Git outputs a relative path for local repository configurations,
|
|
62
|
+
# explicitly provided relative paths, or relative paths used in [include]
|
|
63
|
+
# directives.
|
|
64
|
+
# - **Relative Anchors**: Local repository paths are relative to the repository
|
|
65
|
+
# root. Command-line relative paths are relative to your current working
|
|
66
|
+
# directory. Relative paths from an [include] directive are anchored to
|
|
67
|
+
# the parent configuration file that included them.
|
|
68
|
+
#
|
|
69
|
+
# @return [String]
|
|
70
|
+
#
|
|
71
|
+
# @!attribute [r] key
|
|
72
|
+
#
|
|
73
|
+
# The full key name of the configuration entry (e.g., remote.origin.url)
|
|
74
|
+
#
|
|
75
|
+
# @return [String]
|
|
76
|
+
#
|
|
77
|
+
# @!attribute [r] value
|
|
78
|
+
#
|
|
79
|
+
# The value of the configuration entry
|
|
80
|
+
#
|
|
81
|
+
# @return [String]
|
|
82
|
+
#
|
|
83
|
+
# @api public
|
|
84
|
+
#
|
|
85
|
+
ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do
|
|
86
|
+
# Everything up to the first dot in the {key}
|
|
87
|
+
#
|
|
88
|
+
# Returns an empty string if {key} contains no dot.
|
|
89
|
+
#
|
|
90
|
+
# @example
|
|
91
|
+
# entry.section # => 'remote'
|
|
92
|
+
#
|
|
93
|
+
# @return [String]
|
|
94
|
+
#
|
|
95
|
+
def section = first_dot ? key[0...first_dot] : ''
|
|
96
|
+
|
|
97
|
+
# Everything between the first and last dot in the {key}
|
|
98
|
+
#
|
|
99
|
+
# Returns an empty string if {key} has no subsection (zero or one dot).
|
|
100
|
+
#
|
|
101
|
+
# @example
|
|
102
|
+
# entry.subsection # => 'origin'
|
|
103
|
+
#
|
|
104
|
+
# @return [String]
|
|
105
|
+
#
|
|
106
|
+
def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : ''
|
|
107
|
+
|
|
108
|
+
# Everything after the last dot in the {key}
|
|
109
|
+
#
|
|
110
|
+
# Returns the full {key} if {key} contains no dot.
|
|
111
|
+
#
|
|
112
|
+
# @example
|
|
113
|
+
# entry.variable # => 'url'
|
|
114
|
+
#
|
|
115
|
+
# @return [String]
|
|
116
|
+
#
|
|
117
|
+
def variable = last_dot ? key[(last_dot + 1)..] : key
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
def first_dot = key.index('.')
|
|
122
|
+
|
|
123
|
+
def last_dot = key.rindex('.')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
module Parsers
|
|
127
|
+
# Parser for `git config --get` and `git config --list` output
|
|
128
|
+
# when called with `--show-scope --show-origin --null`.
|
|
129
|
+
#
|
|
130
|
+
# @api private
|
|
131
|
+
#
|
|
132
|
+
module ConfigEntry
|
|
133
|
+
module_function
|
|
134
|
+
|
|
135
|
+
# Parse `git config --get --show-scope --show-origin --null` output.
|
|
136
|
+
#
|
|
137
|
+
# Output format (per entry): `scope\0origin\0value\0`
|
|
138
|
+
# The key name is not present in --get output; it must be supplied.
|
|
139
|
+
#
|
|
140
|
+
# @param key [String] the config key name that was queried
|
|
141
|
+
# @param output [String] raw stdout from the command
|
|
142
|
+
# @return [Git::ConfigEntryInfo, nil] the parsed entry, or nil if not found
|
|
143
|
+
#
|
|
144
|
+
def parse_get(key, output)
|
|
145
|
+
return nil if output.empty?
|
|
146
|
+
|
|
147
|
+
scope, origin, value = output.split("\0", -1)
|
|
148
|
+
Git::ConfigEntryInfo.new(scope: scope, origin: origin, key: key, value: value)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Parse `git config --get-all --show-scope --show-origin --null` output.
|
|
152
|
+
#
|
|
153
|
+
# Output format (per entry): `scope\0origin\0value\0`
|
|
154
|
+
# The key name is not present in --get-all output; it must be supplied.
|
|
155
|
+
# Entries repeat back-to-back in the same string.
|
|
156
|
+
#
|
|
157
|
+
# @param key [String] the config key name that was queried
|
|
158
|
+
# @param output [String] raw stdout from the command
|
|
159
|
+
# @return [Array<Git::ConfigEntryInfo>] the parsed entries
|
|
160
|
+
#
|
|
161
|
+
def parse_get_all(key, output)
|
|
162
|
+
return [] if output.empty?
|
|
163
|
+
|
|
164
|
+
tokens = output.split("\0", -1)
|
|
165
|
+
tokens.pop if tokens.last && tokens.last.empty?
|
|
166
|
+
tokens.each_slice(3).map do |scope, origin, value|
|
|
167
|
+
Git::ConfigEntryInfo.new(scope: scope, origin: origin, key: key, value: value)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Parse `git config --list --show-scope --show-origin --null` output.
|
|
172
|
+
#
|
|
173
|
+
# Also used for `--get-regexp` and `--get-urlmatch` output, which share
|
|
174
|
+
# the same format.
|
|
175
|
+
#
|
|
176
|
+
# Output format (per entry): `scope\0origin\0key\nvalue\0`
|
|
177
|
+
# Entries repeat back-to-back in the same string.
|
|
178
|
+
#
|
|
179
|
+
# @param output [String] raw stdout from the command
|
|
180
|
+
# @return [Array<Git::ConfigEntryInfo>] the parsed entries
|
|
181
|
+
#
|
|
182
|
+
def parse_list(output)
|
|
183
|
+
return [] if output.empty?
|
|
184
|
+
|
|
185
|
+
tokens = output.split("\0", -1)
|
|
186
|
+
tokens.pop if tokens.last && tokens.last.empty?
|
|
187
|
+
tokens.each_slice(3).map do |scope, origin, key_value|
|
|
188
|
+
key, value = key_value.split("\n", 2)
|
|
189
|
+
Git::ConfigEntryInfo.new(scope: scope, origin: origin, key: key, value: value || '')
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Designed to be included in the Git module and the Git::Repository module
|
|
196
|
+
#
|
|
197
|
+
# The including/extending class must implement {#execution_context} and
|
|
198
|
+
# {#assert_valid_scope!}.
|
|
199
|
+
#
|
|
200
|
+
module Configuring # rubocop:disable Metrics/ModuleLength
|
|
201
|
+
# @!group Read Operations
|
|
202
|
+
|
|
203
|
+
CONFIG_GET_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes type default].freeze
|
|
204
|
+
private_constant :CONFIG_GET_ALLOWED_OPTS
|
|
205
|
+
|
|
206
|
+
# @return [Git::ConfigEntryInfo, nil] nil if the key is not found
|
|
207
|
+
def config_get(name, value_regex = nil, **options)
|
|
208
|
+
Private.assert_valid_opts!(CONFIG_GET_ALLOWED_OPTS, **options)
|
|
209
|
+
assert_valid_scope!(**options)
|
|
210
|
+
options = options.merge(show_scope: true, show_origin: true, null: true)
|
|
211
|
+
cmd = Git::Commands::ConfigOptionSyntax::Get.new(execution_context)
|
|
212
|
+
output = cmd.call(name, value_regex, **options).stdout
|
|
213
|
+
Git::Parsers::ConfigEntry.parse_get(name, output)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
CONFIG_GET_ALL_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes type].freeze
|
|
217
|
+
private_constant :CONFIG_GET_ALL_ALLOWED_OPTS
|
|
218
|
+
|
|
219
|
+
# @return [Array<Git::ConfigEntryInfo>]
|
|
220
|
+
def config_get_all(name, value_regex = nil, **options)
|
|
221
|
+
Private.assert_valid_opts!(CONFIG_GET_ALL_ALLOWED_OPTS, **options)
|
|
222
|
+
assert_valid_scope!(**options)
|
|
223
|
+
options = options.merge(show_scope: true, show_origin: true, null: true)
|
|
224
|
+
cmd = Git::Commands::ConfigOptionSyntax::GetAll.new(execution_context)
|
|
225
|
+
output = cmd.call(name, value_regex, **options).stdout
|
|
226
|
+
Git::Parsers::ConfigEntry.parse_get_all(name, output)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# `git config --get --type=color [--default=<default>]` is preferred over
|
|
230
|
+
# --get-color
|
|
231
|
+
#
|
|
232
|
+
# def config_get_color(name, default = nil, **)
|
|
233
|
+
# ...
|
|
234
|
+
# end
|
|
235
|
+
|
|
236
|
+
CONFIG_GET_COLORBOOL_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes].freeze
|
|
237
|
+
private_constant :CONFIG_GET_COLORBOOL_ALLOWED_OPTS
|
|
238
|
+
|
|
239
|
+
# @return [String] always 'true' or 'false'
|
|
240
|
+
def config_get_colorbool(name, stdout_is_tty = nil, **)
|
|
241
|
+
Private.assert_valid_opts!(CONFIG_GET_COLORBOOL_ALLOWED_OPTS, **)
|
|
242
|
+
assert_valid_scope!(**)
|
|
243
|
+
cmd = Git::Commands::ConfigOptionSyntax::GetColorBool.new(execution_context)
|
|
244
|
+
cmd.call(name, stdout_is_tty, **).stdout.chomp
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
CONFIG_GET_REGEXP_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes type].freeze
|
|
248
|
+
private_constant :CONFIG_GET_REGEXP_ALLOWED_OPTS
|
|
249
|
+
|
|
250
|
+
# @return [Array<Git::ConfigEntryInfo>]
|
|
251
|
+
def config_get_regexp(name_regex, value_regex = nil, **options)
|
|
252
|
+
Private.assert_valid_opts!(CONFIG_GET_REGEXP_ALLOWED_OPTS, **options)
|
|
253
|
+
assert_valid_scope!(**options)
|
|
254
|
+
options = options.merge(show_scope: true, show_origin: true, null: true)
|
|
255
|
+
cmd = Git::Commands::ConfigOptionSyntax::GetRegexp.new(execution_context)
|
|
256
|
+
output = cmd.call(name_regex, value_regex, **options).stdout
|
|
257
|
+
Git::Parsers::ConfigEntry.parse_list(output)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
CONFIG_GET_URLMATCH_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes type].freeze
|
|
261
|
+
private_constant :CONFIG_GET_URLMATCH_ALLOWED_OPTS
|
|
262
|
+
|
|
263
|
+
# @return [Array<Git::ConfigEntryInfo>]
|
|
264
|
+
def config_get_urlmatch(name, url, **options)
|
|
265
|
+
Private.assert_valid_opts!(CONFIG_GET_URLMATCH_ALLOWED_OPTS, **options)
|
|
266
|
+
assert_valid_scope!(**options)
|
|
267
|
+
options = options.merge(show_scope: true, show_origin: true, null: true)
|
|
268
|
+
cmd = Git::Commands::ConfigOptionSyntax::GetUrlmatch.new(execution_context)
|
|
269
|
+
output = cmd.call(name, url, **options).stdout
|
|
270
|
+
Git::Parsers::ConfigEntry.parse_list(output)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
CONFIG_LIST_ALLOWED_OPTS = %i[global system local worktree file f blob includes no_includes type].freeze
|
|
274
|
+
private_constant :CONFIG_LIST_ALLOWED_OPTS
|
|
275
|
+
|
|
276
|
+
# @return [Array<Git::ConfigEntryInfo>]
|
|
277
|
+
def config_list(**options)
|
|
278
|
+
Private.assert_valid_opts!(CONFIG_LIST_ALLOWED_OPTS, **options)
|
|
279
|
+
assert_valid_scope!(**options)
|
|
280
|
+
options = options.merge(show_scope: true, show_origin: true, null: true)
|
|
281
|
+
cmd = Git::Commands::ConfigOptionSyntax::List.new(execution_context)
|
|
282
|
+
output = cmd.call(**options).stdout
|
|
283
|
+
Git::Parsers::ConfigEntry.parse_list(output)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# @!endgroup
|
|
287
|
+
|
|
288
|
+
# @!group Write Operations
|
|
289
|
+
|
|
290
|
+
CONFIG_ADD_ALLOWED_OPTS = %i[global system local worktree file f blob type].freeze
|
|
291
|
+
private_constant :CONFIG_ADD_ALLOWED_OPTS
|
|
292
|
+
|
|
293
|
+
# @return [void]
|
|
294
|
+
#
|
|
295
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
296
|
+
#
|
|
297
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
298
|
+
def config_add(name, value, **)
|
|
299
|
+
Private.assert_valid_opts!(CONFIG_ADD_ALLOWED_OPTS, **)
|
|
300
|
+
assert_valid_scope!(**)
|
|
301
|
+
cmd = Git::Commands::ConfigOptionSyntax::Add.new(execution_context)
|
|
302
|
+
cmd.call(name, value, **)
|
|
303
|
+
nil
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
CONFIG_REMOVE_SECTION_ALLOWED_OPTS = %i[global system local worktree file f blob].freeze
|
|
307
|
+
private_constant :CONFIG_REMOVE_SECTION_ALLOWED_OPTS
|
|
308
|
+
|
|
309
|
+
# @return [void]
|
|
310
|
+
#
|
|
311
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
312
|
+
#
|
|
313
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
314
|
+
def config_remove_section(name, **)
|
|
315
|
+
Private.assert_valid_opts!(CONFIG_REMOVE_SECTION_ALLOWED_OPTS, **)
|
|
316
|
+
assert_valid_scope!(**)
|
|
317
|
+
cmd = Git::Commands::ConfigOptionSyntax::RemoveSection.new(execution_context)
|
|
318
|
+
cmd.call(name, **)
|
|
319
|
+
nil
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
CONFIG_RENAME_SECTION_ALLOWED_OPTS = %i[global system local worktree file f blob].freeze
|
|
323
|
+
private_constant :CONFIG_RENAME_SECTION_ALLOWED_OPTS
|
|
324
|
+
|
|
325
|
+
# @return [void]
|
|
326
|
+
#
|
|
327
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
328
|
+
#
|
|
329
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
330
|
+
def config_rename_section(old_name, new_name, **)
|
|
331
|
+
Private.assert_valid_opts!(CONFIG_RENAME_SECTION_ALLOWED_OPTS, **)
|
|
332
|
+
assert_valid_scope!(**)
|
|
333
|
+
cmd = Git::Commands::ConfigOptionSyntax::RenameSection.new(execution_context)
|
|
334
|
+
cmd.call(old_name, new_name, **)
|
|
335
|
+
nil
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
CONFIG_REPLACE_ALL_ALLOWED_OPTS = %i[global system local worktree file f blob type].freeze
|
|
339
|
+
private_constant :CONFIG_REPLACE_ALL_ALLOWED_OPTS
|
|
340
|
+
|
|
341
|
+
# @return [void]
|
|
342
|
+
#
|
|
343
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
344
|
+
#
|
|
345
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
346
|
+
def config_replace_all(name, value, value_regex = nil, **)
|
|
347
|
+
Private.assert_valid_opts!(CONFIG_REPLACE_ALL_ALLOWED_OPTS, **)
|
|
348
|
+
assert_valid_scope!(**)
|
|
349
|
+
cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(execution_context)
|
|
350
|
+
cmd.call(name, value, value_regex, **)
|
|
351
|
+
nil
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
CONFIG_SET_ALLOWED_OPTS = %i[global system local worktree file f blob type].freeze
|
|
355
|
+
private_constant :CONFIG_SET_ALLOWED_OPTS
|
|
356
|
+
|
|
357
|
+
# @return [void]
|
|
358
|
+
#
|
|
359
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
360
|
+
#
|
|
361
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
362
|
+
def config_set(name, value, **)
|
|
363
|
+
Private.assert_valid_opts!(CONFIG_SET_ALLOWED_OPTS, **)
|
|
364
|
+
assert_valid_scope!(**)
|
|
365
|
+
cmd = Git::Commands::ConfigOptionSyntax::Set.new(execution_context)
|
|
366
|
+
cmd.call(name, value, **)
|
|
367
|
+
nil
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
CONFIG_UNSET_ALLOWED_OPTS = %i[global system local worktree file f blob].freeze
|
|
371
|
+
private_constant :CONFIG_UNSET_ALLOWED_OPTS
|
|
372
|
+
|
|
373
|
+
# @return [void]
|
|
374
|
+
#
|
|
375
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
376
|
+
#
|
|
377
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
378
|
+
def config_unset(name, value_regex = nil, **)
|
|
379
|
+
Private.assert_valid_opts!(CONFIG_UNSET_ALLOWED_OPTS, **)
|
|
380
|
+
assert_valid_scope!(**)
|
|
381
|
+
cmd = Git::Commands::ConfigOptionSyntax::Unset.new(execution_context)
|
|
382
|
+
cmd.call(name, value_regex, **)
|
|
383
|
+
nil
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
CONFIG_UNSET_ALL_ALLOWED_OPTS = %i[global system local worktree file f blob].freeze
|
|
387
|
+
private_constant :CONFIG_UNSET_ALL_ALLOWED_OPTS
|
|
388
|
+
|
|
389
|
+
# @return [void]
|
|
390
|
+
#
|
|
391
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
392
|
+
#
|
|
393
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
394
|
+
def config_unset_all(name, value_regex = nil, **)
|
|
395
|
+
Private.assert_valid_opts!(CONFIG_UNSET_ALL_ALLOWED_OPTS, **)
|
|
396
|
+
assert_valid_scope!(**)
|
|
397
|
+
cmd = Git::Commands::ConfigOptionSyntax::UnsetAll.new(execution_context)
|
|
398
|
+
cmd.call(name, value_regex, **)
|
|
399
|
+
nil
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
# @!endgroup
|
|
403
|
+
|
|
404
|
+
private
|
|
405
|
+
|
|
406
|
+
# @abstract Including/extending class must implement execution_context
|
|
407
|
+
#
|
|
408
|
+
# @return [Git::ExecutionContext]
|
|
409
|
+
#
|
|
410
|
+
def execution_context
|
|
411
|
+
raise NotImplementedError
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# @abstract Including/extending class must implement assert_valid_scope!
|
|
415
|
+
#
|
|
416
|
+
# Called before every config operation to validate that the requested scope
|
|
417
|
+
# is appropriate for the context (e.g., repository-specific scopes such as
|
|
418
|
+
# `local` are not valid when called without a repository).
|
|
419
|
+
#
|
|
420
|
+
# @raise [ArgumentError] if the scope is not permitted in this context
|
|
421
|
+
#
|
|
422
|
+
# @return [void]
|
|
423
|
+
#
|
|
424
|
+
def assert_valid_scope!(**)
|
|
425
|
+
raise NotImplementedError
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Internal helpers local to {Git::Configuring}
|
|
429
|
+
#
|
|
430
|
+
# @api private
|
|
431
|
+
#
|
|
432
|
+
module Private
|
|
433
|
+
module_function
|
|
434
|
+
|
|
435
|
+
# Validate that `options` contains only keys listed in `allowed`
|
|
436
|
+
#
|
|
437
|
+
# @example Reject an undocumented option
|
|
438
|
+
# Private.assert_valid_opts!(%i[all force], bogus: true)
|
|
439
|
+
# #=> raises ArgumentError: Unknown options: bogus
|
|
440
|
+
#
|
|
441
|
+
# @param allowed [Array<Symbol>] the keys permitted by the facade method
|
|
442
|
+
#
|
|
443
|
+
# @param options [Hash] the options hash provided by the caller
|
|
444
|
+
#
|
|
445
|
+
# @return [void]
|
|
446
|
+
#
|
|
447
|
+
# @raise [ArgumentError] when `options` contains any key not in `allowed`
|
|
448
|
+
#
|
|
449
|
+
def assert_valid_opts!(allowed, **options)
|
|
450
|
+
unknown = options.keys - allowed
|
|
451
|
+
return if unknown.empty?
|
|
452
|
+
|
|
453
|
+
raise ArgumentError, "Unknown options: #{unknown.join(', ')}"
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
private_constant :Private
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
REPOSITORY_SPECIFIC_SCOPES = %i[local worktree blob].freeze
|
|
460
|
+
private_constant :REPOSITORY_SPECIFIC_SCOPES
|
|
461
|
+
|
|
462
|
+
# Reopens Git::Repository to mix in config read/write operations.
|
|
463
|
+
#
|
|
464
|
+
# In the real implementation this `include` lives in
|
|
465
|
+
# `lib/git/repository/configuring.rb` and is picked up by the
|
|
466
|
+
# `Git::Repository` class definition in `lib/git/repository.rb`.
|
|
467
|
+
class Repository
|
|
468
|
+
# Mixes in config_get, config_list, config_set, etc.
|
|
469
|
+
include Git::Configuring
|
|
470
|
+
|
|
471
|
+
private
|
|
472
|
+
|
|
473
|
+
# @return [Git::ExecutionContext::Repository]
|
|
474
|
+
attr_reader :execution_context
|
|
475
|
+
|
|
476
|
+
# All scopes are permitted when called with a repository context.
|
|
477
|
+
def assert_valid_scope!(**)
|
|
478
|
+
# All scopes allowed
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
# Enables calling Git.config_get('user.name')
|
|
483
|
+
extend Git::Configuring
|
|
484
|
+
|
|
485
|
+
# Returns a global execution context for non-repository config operations.
|
|
486
|
+
#
|
|
487
|
+
# Overrides the abstract {Git::Configuring#execution_context} for the
|
|
488
|
+
# module-level case.
|
|
489
|
+
#
|
|
490
|
+
# @return [Git::ExecutionContext::Global]
|
|
491
|
+
def self.execution_context
|
|
492
|
+
Git::ExecutionContext::Global.new
|
|
493
|
+
end
|
|
494
|
+
private_class_method :execution_context
|
|
495
|
+
|
|
496
|
+
def self.assert_valid_scope!(**options)
|
|
497
|
+
repo_scopes = options.keys.select { |k| options[k] && REPOSITORY_SPECIFIC_SCOPES.include?(k) }
|
|
498
|
+
raise ArgumentError, "scope #{repo_scopes.first} requires a repository" if repo_scopes.any?
|
|
499
|
+
end
|
|
500
|
+
private_class_method :assert_valid_scope!
|
|
501
|
+
end
|
data/tasks/gem_tasks.rake
CHANGED
data/tasks/rspec.rake
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
|
|
5
|
+
# Run all specs
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
7
|
+
t.pattern = 'spec/**/*_spec.rb'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Run only unit specs (mocked, fast)
|
|
11
|
+
RSpec::Core::RakeTask.new('spec:unit') do |t|
|
|
12
|
+
t.pattern = 'spec/unit/**/*_spec.rb'
|
|
13
|
+
# On JRuby, use 'documentation' formatter so each test name is printed before
|
|
14
|
+
# it runs. When the suite hangs, the last printed line identifies the blocking
|
|
15
|
+
# test. Mirrors the same diagnostic added to spec:integration in PR #1274.
|
|
16
|
+
t.rspec_opts = '--format documentation' if RUBY_ENGINE == 'jruby'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Run only integration specs (real git, slower)
|
|
20
|
+
RSpec::Core::RakeTask.new('spec:integration') do |t|
|
|
21
|
+
t.pattern = 'spec/integration/**/*_spec.rb'
|
|
22
|
+
# On JRuby, override the default Fuubar formatter with 'documentation' so that
|
|
23
|
+
# each test name is printed before it runs. This makes CI logs useful when the
|
|
24
|
+
# suite hangs: the last printed test is the one that caused the hang.
|
|
25
|
+
t.rspec_opts = '--format documentation' if RUBY_ENGINE == 'jruby'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Run all specs in parallel
|
|
29
|
+
desc 'Run all specs in parallel'
|
|
30
|
+
task 'spec:parallel' do
|
|
31
|
+
sh 'bundle exec parallel_rspec spec/'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Run only unit specs in parallel
|
|
35
|
+
desc 'Run unit specs in parallel'
|
|
36
|
+
task 'spec:unit:parallel' do
|
|
37
|
+
sh 'bundle exec parallel_rspec spec/unit/'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Run only integration specs in parallel
|
|
41
|
+
desc 'Run integration specs in parallel'
|
|
42
|
+
task 'spec:integration:parallel' do
|
|
43
|
+
sh 'bundle exec parallel_rspec spec/integration/'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
CLEAN << 'coverage'
|
|
47
|
+
CLEAN << '.rspec_status'
|
|
48
|
+
CLEAN << 'rspec-report.xml'
|
data/tasks/test.rake
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
desc 'Run Unit Tests'
|
|
3
|
+
desc 'Run Unit Tests (TestUnit)'
|
|
4
4
|
task :test do
|
|
5
5
|
sh 'ruby bin/test'
|
|
6
6
|
|
|
@@ -11,3 +11,15 @@ task :test do
|
|
|
11
11
|
#
|
|
12
12
|
# $ bin/test test_archive.rb test_object.rb
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
desc 'Run Test::Unit tests in parallel'
|
|
16
|
+
task 'test:parallel' do
|
|
17
|
+
# Ensure git global config is set (normally done by bin/test for serial runs).
|
|
18
|
+
# CI runners may not have a git identity configured.
|
|
19
|
+
sh 'git config --global user.email "git@example.com"' if `git config --global user.email`.empty?
|
|
20
|
+
sh 'git config --global user.name "GitExample"' if `git config --global user.name`.empty?
|
|
21
|
+
sh 'git config --global init.defaultBranch main' if `git config --global init.defaultBranch`.empty?
|
|
22
|
+
|
|
23
|
+
sh({ 'PARALLEL_TESTS_EXECUTABLE' => 'ruby -Itests' },
|
|
24
|
+
"bundle exec parallel_test tests/units/ --suffix 'test_.+\\.rb$'")
|
|
25
|
+
end
|
data/tasks/yard.rake
CHANGED
|
@@ -4,20 +4,47 @@
|
|
|
4
4
|
# This project uses the redcarpet gem which can not be installed on JRuby.
|
|
5
5
|
#
|
|
6
6
|
unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
|
|
7
|
+
# yard:build
|
|
8
|
+
|
|
7
9
|
require 'yard'
|
|
8
10
|
|
|
9
|
-
YARD::Rake::YardocTask.new
|
|
11
|
+
YARD::Rake::YardocTask.new('yard:build') do |t|
|
|
12
|
+
t.files = %w[lib/**/*.rb]
|
|
13
|
+
t.stats_options = ['--list-undoc']
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
CLEAN << '.yardoc'
|
|
11
17
|
CLEAN << 'doc'
|
|
12
18
|
|
|
19
|
+
# yard:audit
|
|
20
|
+
|
|
21
|
+
desc 'Run yardstick to show missing YARD doc elements'
|
|
22
|
+
task :'yard:audit' do
|
|
23
|
+
sh "yardstick 'lib/**/*.rb'"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# yard:coverage
|
|
27
|
+
|
|
13
28
|
require 'yardstick/rake/verify'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
|
|
30
|
+
Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
|
|
31
|
+
verify.threshold = 75
|
|
32
|
+
verify.require_exact_threshold = false
|
|
17
33
|
end
|
|
18
34
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
# yard:example-test
|
|
36
|
+
|
|
37
|
+
require 'yard_example_test/rake'
|
|
38
|
+
|
|
39
|
+
YardExampleTest::RakeTask.new('yard:example-test') do |task|
|
|
40
|
+
task.pattern = 'lib/git/commands/arguments.rb'
|
|
22
41
|
end
|
|
42
|
+
|
|
43
|
+
# yard
|
|
44
|
+
|
|
45
|
+
# Do not include yard:audit in the yard task because there are too many
|
|
46
|
+
# missing YARD doc elements
|
|
47
|
+
#
|
|
48
|
+
desc 'Run YARD documentation tasks (build, coverage, example-test)'
|
|
49
|
+
task yard: %i[yard:build yard:coverage yard:example-test]
|
|
23
50
|
end
|