Skip to content

Commit d84097b

Browse files
committed
Update YARDoc for a few a few method
1 parent 437f57f commit d84097b

File tree

2 files changed

+86
-56
lines changed

2 files changed

+86
-56
lines changed

lib/git/base.rb

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
require 'open3'
33

44
module Git
5-
# Git::Base is the main public interface for interacting with Git commands.
5+
# The main public interface for interacting with Git commands
66
#
77
# Instead of creating a Git::Base directly, obtain a Git::Base instance by
88
# calling one of the follow {Git} class methods: {Git.open}, {Git.init},
99
# {Git.clone}, or {Git.bare}.
1010
#
11+
# @api public
12+
#
1113
class Base
1214
# (see Git.bare)
1315
def self.bare(git_dir, options = {})
@@ -119,6 +121,62 @@ def initialize(options = {})
119121
@index = options[:index] ? Git::Index.new(options[:index], false) : nil
120122
end
121123

124+
# Update the index from the current worktree to prepare the for the next commit
125+
#
126+
# @example
127+
# lib.add('path/to/file')
128+
# lib.add(['path/to/file1','path/to/file2'])
129+
# lib.add(all: true)
130+
#
131+
# @param [String, Array<String>] paths a file or files to be added to the repository (relative to the worktree root)
132+
# @param [Hash] options
133+
#
134+
# @option options [Boolean] :all Add, modify, and remove index entries to match the worktree
135+
# @option options [Boolean] :force Allow adding otherwise ignored files
136+
#
137+
def add(paths = '.', **options)
138+
self.lib.add(paths, options)
139+
end
140+
141+
# adds a new remote to this repository
142+
# url can be a git url or a Git::Base object if it's a local reference
143+
#
144+
# @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
145+
# @git.fetch('scotts_git')
146+
# @git.merge('scotts_git/master')
147+
#
148+
# Options:
149+
# :fetch => true
150+
# :track => <branch_name>
151+
def add_remote(name, url, opts = {})
152+
url = url.repo.path if url.is_a?(Git::Base)
153+
self.lib.remote_add(name, url, opts)
154+
Git::Remote.new(self, name)
155+
end
156+
157+
# Create a new git tag
158+
#
159+
# @example
160+
# repo.add_tag('tag_name', object_reference)
161+
# repo.add_tag('tag_name', object_reference, {:options => 'here'})
162+
# repo.add_tag('tag_name', {:options => 'here'})
163+
#
164+
# @param [String] name The name of the tag to add
165+
# @param [Hash] options Opstions to pass to `git tag`.
166+
# See [git-tag](https://git-scm.com/docs/git-tag) for more details.
167+
# @option options [boolean] :annotate Make an unsigned, annotated tag object
168+
# @option options [boolean] :a An alias for the `:annotate` option
169+
# @option options [boolean] :d Delete existing tag with the given names.
170+
# @option options [boolean] :f Replace an existing tag with the given name (instead of failing)
171+
# @option options [String] :message Use the given tag message
172+
# @option options [String] :m An alias for the `:message` option
173+
# @option options [boolean] :s Make a GPG-signed tag.
174+
#
175+
def add_tag(name, *options)
176+
self.lib.tag(name, *options)
177+
self.tag(name)
178+
end
179+
122180
# changes current working directory for a block
123181
# to the git working directory
124182
#
@@ -251,29 +309,6 @@ def grep(string, path_limiter = nil, opts = {})
251309
self.object('HEAD').grep(string, path_limiter, opts)
252310
end
253311

254-
# updates the repository index using the working directory content
255-
#
256-
# @example
257-
# git.add
258-
# git.add('path/to/file')
259-
# git.add(['path/to/file1','path/to/file2'])
260-
# git.add(:all => true)
261-
#
262-
# options:
263-
# :all => true
264-
#
265-
# @param [String,Array] paths files paths to be added (optional, default='.')
266-
# @param [Hash] options
267-
# @option options [boolean] :all
268-
# Update the index not only where the working tree has a file matching
269-
# <pathspec> but also where the index already has an entry.
270-
# See [the --all option to git-add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--A)
271-
# for more details.
272-
#
273-
def add(paths = '.', **options)
274-
self.lib.add(paths, options)
275-
end
276-
277312
# removes file(s) from the git repository
278313
def rm(path = '.', opts = {})
279314
self.lib.rm(path, opts)
@@ -434,22 +469,6 @@ def remotes
434469
self.lib.remotes.map { |r| Git::Remote.new(self, r) }
435470
end
436471

437-
# adds a new remote to this repository
438-
# url can be a git url or a Git::Base object if it's a local reference
439-
#
440-
# @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
441-
# @git.fetch('scotts_git')
442-
# @git.merge('scotts_git/master')
443-
#
444-
# Options:
445-
# :fetch => true
446-
# :track => <branch_name>
447-
def add_remote(name, url, opts = {})
448-
url = url.repo.path if url.is_a?(Git::Base)
449-
self.lib.remote_add(name, url, opts)
450-
Git::Remote.new(self, name)
451-
end
452-
453472
# sets the url for a remote
454473
# url can be a git url or a Git::Base object if it's a local reference
455474
#
@@ -473,7 +492,7 @@ def tags
473492
self.lib.tags.map { |r| tag(r) }
474493
end
475494

476-
# Creates a new git tag (Git::Tag)
495+
# Create a new git tag
477496
#
478497
# @example
479498
# repo.add_tag('tag_name', object_reference)

lib/git/lib.rb

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,23 @@ class Lib
3838

3939
# Create a new Git::Lib object
4040
#
41-
# @param [Git::Base, Hash] base An object that passes in values for
42-
# @git_work_dir, @git_dir, and @git_index_file
41+
# @overload initialize(base, logger)
4342
#
44-
# @param [Logger] logger
43+
# @param base [Hash] the hash containing paths to the Git working copy,
44+
# the Git repository directory, and the Git index file.
4545
#
46-
# @option base [Pathname] :working_directory
47-
# @option base [Pathname] :repository
48-
# @option base [Pathname] :index
46+
# @option base [Pathname] :working_directory
47+
# @option base [Pathname] :repository
48+
# @option base [Pathname] :index
49+
#
50+
# @param [Logger] logger
51+
#
52+
# @overload initialize(base, logger)
53+
#
54+
# @param base [#dir, #repo, #index] an object with methods to get the Git worktree (#dir),
55+
# the Git repository directory (#repo), and the Git index file (#index).
56+
#
57+
# @param [Logger] logger
4958
#
5059
def initialize(base = nil, logger = nil)
5160
@git_dir = nil
@@ -670,18 +679,20 @@ def global_config_set(name, value)
670679
command('config', '--global', name, value)
671680
end
672681

673-
# updates the repository index using the working directory content
674-
#
675-
# lib.add('path/to/file')
676-
# lib.add(['path/to/file1','path/to/file2'])
677-
# lib.add(:all => true)
682+
683+
# Update the index from the current worktree to prepare the for the next commit
678684
#
679-
# options:
680-
# :all => true
681-
# :force => true
685+
# @example
686+
# lib.add('path/to/file')
687+
# lib.add(['path/to/file1','path/to/file2'])
688+
# lib.add(:all => true)
682689
#
683-
# @param [String,Array] paths files paths to be added to the repository
690+
# @param [String, Array<String>] paths files to be added to the repository (relative to the worktree root)
684691
# @param [Hash] options
692+
#
693+
# @option options [Boolean] :all Add, modify, and remove index entries to match the worktree
694+
# @option options [Boolean] :force Allow adding otherwise ignored files
695+
#
685696
def add(paths='.',options={})
686697
arr_opts = []
687698

0 commit comments

Comments
 (0)