Module: RubyGit
- Defined in:
- lib/ruby_git.rb,
lib/ruby_git/errors.rb,
lib/ruby_git/status.rb,
lib/ruby_git/version.rb,
lib/ruby_git/worktree.rb,
lib/ruby_git/repository.rb,
lib/ruby_git/command_line.rb,
lib/ruby_git/status/entry.rb,
lib/ruby_git/status/stash.rb,
lib/ruby_git/status/branch.rb,
lib/ruby_git/status/parser.rb,
lib/ruby_git/status/report.rb,
lib/ruby_git/option_validators.rb,
lib/ruby_git/command_line/result.rb,
lib/ruby_git/command_line/runner.rb,
lib/ruby_git/command_line/options.rb,
lib/ruby_git/status/ignored_entry.rb,
lib/ruby_git/status/renamed_entry.rb,
lib/ruby_git/status/ordinary_entry.rb,
lib/ruby_git/status/unmerged_entry.rb,
lib/ruby_git/status/untracked_entry.rb,
lib/ruby_git/status/submodule_status.rb,
lib/ruby_git/command_line/encoding_normalizer.rb
Overview
The RubyGit module provides a Ruby API that is an object-oriented wrapper around
the git
command line. It is intended to make automating both simple and complex Git
interactions easier. To accomplish this, it ties each action you can do with git
to
the type of object that action operates on.
There are three main objects in RubyGit:
- Worktree: The directory tree of actual checked out files. The working tree normally contains the contents of the HEAD commit's tree, plus any local changes that you have made but not yet committed.
- Index: The index is used as a staging area between your working tree and your repository. You can use the index to build up a set of changes that you want to commit together. When you create a commit, what is committed is what is currently in the index, not what is in your working directory.
- Repository: The repository stores the files in a project, their history, and other meta data like commit information, tags, and branches.
Defined Under Namespace
Modules: CommandLine, OptionValidators, Status Classes: ArgumentError, CommandLineError, Error, FailedError, ProcessIOError, Repository, SignaledError, SpawnError, TimeoutError, UnexpectedResultError, Worktree
Constant Summary collapse
- VERSION =
The ruby_git gem version
'0.4.0'
Class Attribute Summary collapse
-
.binary_path ⇒ String
The path to the git binary used by the RubyGit gem.
-
.logger ⇒ Logger
The logger used by the RubyGit gem (Logger.new(nil) by default).
Class Method Summary collapse
-
.binary_version ⇒ Array<Integer>
The version of git referred to by the path.
-
.clone(repository_url, to_path: '') ⇒ RubyGit::Worktree
Copy the remote repository and checkout the default branch.
-
.init(worktree_path, initial_branch:) ⇒ RubyGit::Worktree
Create an empty Git repository under the root working tree
path
. -
.open(worktree_path) ⇒ RubyGit::Worktree
Open an existing Git working tree that contains worktree_path.
Class Attribute Details
.binary_path ⇒ String
The path to the git binary used by the RubyGit gem
If the path is a command name, the command is search for in the PATH.
If the path is a relative path, it relative to the current directory (not recommended as this will change as the current directory is changed).
If the path is an absolute path, it is used as is.
72 73 74 |
# File 'lib/ruby_git.rb', line 72 def binary_path @binary_path end |
.logger ⇒ Logger
The logger used by the RubyGit gem (Logger.new(nil) by default)
51 52 53 |
# File 'lib/ruby_git.rb', line 51 def logger @logger end |
Class Method Details
.binary_version ⇒ Array<Integer>
The version of git referred to by the path
162 163 164 165 |
# File 'lib/ruby_git.rb', line 162 def self.binary_version version_string = RubyGit::CommandLine.run('version').stdout[/\d+\.\d+(\.\d+)+/] version_string.split('.').collect(&:to_i) end |
.clone(repository_url, to_path: '') ⇒ RubyGit::Worktree
Copy the remote repository and checkout the default branch
Clones the repository referred to by repository_url
into a newly created
directory, creates remote-tracking branches for each branch in the cloned repository,
and checks out the default branch in the worktree whose root directory is to_path
.
to_path
will be created if it does not exist. An error is raised if to_path
exists and
not an empty directory.
148 149 150 |
# File 'lib/ruby_git.rb', line 148 def self.clone(repository_url, to_path: '') RubyGit::Worktree.clone(repository_url, to_path:) end |
.init(worktree_path, initial_branch:) ⇒ RubyGit::Worktree
Create an empty Git repository under the root working tree path
If the repository already exists, it will not be overwritten.
91 92 93 |
# File 'lib/ruby_git.rb', line 91 def self.init(worktree_path, initial_branch:) RubyGit::Worktree.init(worktree_path, initial_branch:) end |
.open(worktree_path) ⇒ RubyGit::Worktree
Open an existing Git working tree that contains worktree_path
109 110 111 |
# File 'lib/ruby_git.rb', line 109 def self.open(worktree_path) RubyGit::Worktree.open(worktree_path) end |