Module: ThorSCMVersion

Defined in:
lib/thor-scmversion.rb,
lib/thor-scmversion/errors.rb,
lib/thor-scmversion/version.rb,
lib/thor-scmversion/p4_version.rb,
lib/thor-scmversion/prerelease.rb,
lib/thor-scmversion/git_version.rb,
lib/thor-scmversion/scm_version.rb,
lib/thor-scmversion/shell_utils.rb

Defined Under Namespace

Modules: Perforce Classes: GitError, GitTagDuplicateError, GitVersion, InternalError, InvalidPrereleaseFormatError, MissingP4ConfigException, P4Version, Prerelease, SCMVersionError, ScmVersion, ShellUtils, TagFormatError, Tasks

Constant Summary collapse

VERSION =
IO.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')) rescue "0.0.1"

Class Method Summary collapse

Class Method Details

.file_exists?(current_dir, file) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/thor-scmversion/scm_version.rb', line 19

def file_exists?(current_dir, file)
  return true if File.exist?(file)
  Dir.chdir('..') do
    return false if Dir.pwd == current_dir
    file_exists?(current_dir, file)
  end
end

.is_git?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/thor-scmversion/scm_version.rb', line 15

def is_git?
  file_exists?(Dir.pwd, '.git')
end

.versioner#kind_of? ScmVersion

Figures out whether the repository is managed by git. If not, use p4.

Returns:



7
8
9
10
11
12
13
# File 'lib/thor-scmversion/scm_version.rb', line 7

def versioner
  if is_git?
    return GitVersion
  else
    return P4Version
  end
end

.windows?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/thor-scmversion/p4_version.rb', line 3

def windows?
  RbConfig::CONFIG["arch"] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
end