ruby_git 0.1.3 → 0.3.0
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/.commitlintrc.yml +16 -0
- data/.github/CODEOWNERS +4 -0
- data/.github/workflows/continuous_integration.yml +87 -0
- data/.github/workflows/enforce_conventional_commits.yml +21 -0
- data/.github/workflows/experimental_ruby_builds.yml +65 -0
- data/.gitignore +3 -0
- data/.husky/commit-msg +1 -0
- data/.markdownlint.yml +25 -0
- data/.rubocop.yml +13 -15
- data/.yardopts +6 -1
- data/CHANGELOG.md +76 -20
- data/CONTRIBUTING.md +7 -7
- data/{LICENSE.md → LICENSE.txt} +1 -1
- data/PLAN.md +67 -0
- data/README.md +64 -10
- data/RELEASING.md +5 -54
- data/Rakefile +31 -38
- data/RubyGit Class Diagram.svg +1 -0
- data/bin/command-line-test +189 -0
- data/bin/console +2 -0
- data/bin/setup +13 -2
- data/lib/ruby_git/command_line/options.rb +61 -0
- data/lib/ruby_git/command_line/result.rb +155 -0
- data/lib/ruby_git/command_line/runner.rb +296 -0
- data/lib/ruby_git/command_line.rb +95 -0
- data/lib/ruby_git/encoding_normalizer.rb +49 -0
- data/lib/ruby_git/errors.rb +169 -0
- data/lib/ruby_git/repository.rb +33 -0
- data/lib/ruby_git/status/branch.rb +92 -0
- data/lib/ruby_git/status/entry.rb +162 -0
- data/lib/ruby_git/status/ignored_entry.rb +44 -0
- data/lib/ruby_git/status/ordinary_entry.rb +207 -0
- data/lib/ruby_git/status/parser.rb +203 -0
- data/lib/ruby_git/status/renamed_entry.rb +257 -0
- data/lib/ruby_git/status/report.rb +143 -0
- data/lib/ruby_git/status/stash.rb +33 -0
- data/lib/ruby_git/status/submodule_status.rb +85 -0
- data/lib/ruby_git/status/unmerged_entry.rb +248 -0
- data/lib/ruby_git/status/untracked_entry.rb +52 -0
- data/lib/ruby_git/status.rb +33 -0
- data/lib/ruby_git/version.rb +1 -1
- data/lib/ruby_git/worktree.rb +277 -0
- data/lib/ruby_git.rb +154 -14
- data/package.json +11 -0
- data/ruby_git.gemspec +32 -20
- metadata +146 -45
- data/.travis.yml +0 -13
- data/MAINTAINERS.md +0 -8
- data/lib/ruby_git/file_helpers.rb +0 -42
- data/lib/ruby_git/git_binary.rb +0 -90
- /data/{ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE.md} +0 -0
- /data/{PULL_REQUEST_TEMPLATE.md → .github/PULL_REQUEST_TEMPLATE.md} +0 -0
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyGit
|
4
|
-
# A namespace for several file utility methods that I wish were part of FileUtils.
|
5
|
-
#
|
6
|
-
# @api public
|
7
|
-
#
|
8
|
-
module FileHelpers
|
9
|
-
# Cross platform way to find an executable file within a list of paths
|
10
|
-
#
|
11
|
-
# Works for both Linux/Unix and Windows.
|
12
|
-
#
|
13
|
-
# @example Searching over the PATH for a command
|
14
|
-
# path = FileUtils.which('git')
|
15
|
-
#
|
16
|
-
# @example Overriding the default PATH
|
17
|
-
# path = FileUtils.which('git', ['/usr/bin', '/usr/local/bin'])
|
18
|
-
#
|
19
|
-
# @param [String] cmd The basename of the executable file to search for
|
20
|
-
# @param [Array<String>] paths The list of directories to search for basename in
|
21
|
-
# @param [Array<String>] exts The list of extensions that indicate that a file is executable
|
22
|
-
#
|
23
|
-
# `exts` is for Windows. Other platforms should accept the default.
|
24
|
-
#
|
25
|
-
# @return [Pathname,nil] The path to the first executable file found on the path or
|
26
|
-
# nil an executable file was not found.
|
27
|
-
#
|
28
|
-
def self.which(
|
29
|
-
cmd,
|
30
|
-
paths: ENV['PATH'].split(File::PATH_SEPARATOR),
|
31
|
-
exts: (ENV['PATHEXT']&.split(';') || [''])
|
32
|
-
)
|
33
|
-
raise 'PATH is not set' unless ENV.keys.include?('PATH')
|
34
|
-
|
35
|
-
paths
|
36
|
-
.product(exts)
|
37
|
-
.map { |path, ext| Pathname.new(File.join(path, "#{cmd}#{ext}")) }
|
38
|
-
.reject { |path| path.directory? || !path.executable? }
|
39
|
-
.find { |exe_path| !exe_path.directory? && exe_path.executable? }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/ruby_git/git_binary.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyGit
|
4
|
-
# Sets and tracks the path to a git executable and reports the version
|
5
|
-
#
|
6
|
-
# @api public
|
7
|
-
#
|
8
|
-
class GitBinary
|
9
|
-
# Return a new GitBinary object
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# GitBinary.new
|
13
|
-
#
|
14
|
-
def initialize
|
15
|
-
@path = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
# Sets the path to the git binary
|
19
|
-
#
|
20
|
-
# The given path must point to an executable file or a RuntimeError is raised.
|
21
|
-
#
|
22
|
-
# @example Setting the path to the git binary
|
23
|
-
# git.path = '/usr/local/bin/git'
|
24
|
-
#
|
25
|
-
# @param [String] path the path to a git executable
|
26
|
-
#
|
27
|
-
# @return [Pathname]
|
28
|
-
#
|
29
|
-
# @raise [RuntimeError] A RuntimeError is raised when the path does not refer
|
30
|
-
# to an existing executable file.
|
31
|
-
#
|
32
|
-
def path=(path)
|
33
|
-
new_path = Pathname.new(path)
|
34
|
-
raise "'#{new_path}' does not exist." unless new_path.exist?
|
35
|
-
raise "'#{new_path}' is not a file." unless new_path.file?
|
36
|
-
raise "'#{new_path}' is not executable." unless new_path.executable?
|
37
|
-
|
38
|
-
@path = new_path
|
39
|
-
end
|
40
|
-
|
41
|
-
# Retrieve the path to the git binary
|
42
|
-
#
|
43
|
-
# @example Get the git found on the PATH
|
44
|
-
# git = RubyGit::GitBinary.new
|
45
|
-
# path = git.path
|
46
|
-
#
|
47
|
-
# @return [Pathname] the path to the git binary
|
48
|
-
#
|
49
|
-
# @raise [RuntimeError] if path was not set via `path=` and either PATH is not set
|
50
|
-
# or git was not found on the path.
|
51
|
-
#
|
52
|
-
def path
|
53
|
-
@path || (@path = self.class.default_path)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Get the default path to to a git binary by searching the PATH
|
57
|
-
#
|
58
|
-
# @example Find the pathname to `super_git`
|
59
|
-
# git = RubyGit::GitBinary.new
|
60
|
-
# git.path = git.default_path(basename: 'super_git')
|
61
|
-
#
|
62
|
-
# @param [String] basename The basename of the git command
|
63
|
-
#
|
64
|
-
# @return [Pathname] the path to the git binary found in the path
|
65
|
-
#
|
66
|
-
# @raise [RuntimeError] if either PATH is not set or an executable file
|
67
|
-
# `basename` was not found on the path.
|
68
|
-
#
|
69
|
-
def self.default_path(basename: 'git')
|
70
|
-
RubyGit::FileHelpers.which(basename) || raise("Could not find '#{basename}' in the PATH.")
|
71
|
-
end
|
72
|
-
|
73
|
-
# The version of git referred to by the path
|
74
|
-
#
|
75
|
-
# @example for version 2.28.0
|
76
|
-
# git = RubyGit::GitBinary.new
|
77
|
-
# puts git.version #=> [2,28,0]
|
78
|
-
#
|
79
|
-
# @return [Array<Integer>] an array of integers representing the version.
|
80
|
-
#
|
81
|
-
# @raise [RuntimeError] if path was not set via `path=` and either PATH is not set
|
82
|
-
# or git was not found on the path.
|
83
|
-
#
|
84
|
-
def version
|
85
|
-
output = `#{path} --version`
|
86
|
-
version = output[/\d+\.\d+(\.\d+)+/]
|
87
|
-
version.split('.').collect(&:to_i)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
File without changes
|
File without changes
|