Class: Versioneer::Git
Constant Summary collapse
- H =
Helpers
Instance Attribute Summary
Attributes inherited from Repo
#bump_segment, #environment, #prereleases, #release_pattern, #starting_release
Instance Method Summary collapse
- #commits_since_release ⇒ Object
- #filesystem_dirty? ⇒ Boolean
-
#initialize(file_within_repo, options = nil) ⇒ Git
constructor
A new instance of Git.
- #release ⇒ Object
Methods inherited from Repo
bump, segment_to_i, #to_s, #version
Constructor Details
#initialize(file_within_repo, options = nil) ⇒ Git
Returns a new instance of Git.
7 8 9 10 11 12 13 14 |
# File 'lib/versioneer/git.rb', line 7 def initialize(file_within_repo, =nil) super unless Dir.exist?(File.join(file_within_repo, '.git')) unless H.lines? `git ls-files #{file_within_repo} --error-unmatch #{H.cl_no_stderr}` raise InvalidRepoError, "Not inside a Git repo. (#{file_within_repo})" end end end |
Instance Method Details
#commits_since_release ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/versioneer/git.rb', line 24 def commits_since_release offset = 0 unless (ref = release_ref) unless (ref = first_ref) return 0 end offset = 1 end H.num_of_lines(`git log #{ref}...HEAD --pretty=oneline #{H.cl_no_stderr}`) + offset end |
#filesystem_dirty? ⇒ Boolean
35 36 37 38 |
# File 'lib/versioneer/git.rb', line 35 def filesystem_dirty? system 'git diff-index --quiet HEAD --' $?.exitstatus != 0 end |
#release ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/versioneer/git.rb', line 16 def release if (ref = release_ref) Gem::Version.new(ref.match(release_pattern)[1]) else super end end |