Class: Buildr::GitRelease

Inherits:
Release show all
Defined in:
lib/buildr/core/build.rb

Constant Summary

Constants inherited from Release

Release::THIS_VERSION_PATTERN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Release

add, #extract_version, find, list, #make, #tag_name=

Class Method Details

.applies_to?Boolean



427
428
429
430
431
432
433
434
435
436
437
# File 'lib/buildr/core/build.rb', line 427

def applies_to?
  if File.exist? '.git/config'
    true
  else
    curr_pwd = Dir.pwd
    Dir.chdir('..') do
      return false if curr_pwd == Dir.pwd # Means going up one level is not possible.
      applies_to?
    end
  end
end

Instance Method Details

#checkObject

Fails if one of theses 2 conditions are not met:

1. the repository is clean: no content staged or unstaged
2. some remote repositories are defined but the current branch does not track any


443
444
445
446
447
448
# File 'lib/buildr/core/build.rb', line 443

def check
  super
  uncommitted = Git.uncommitted_files
  fail "Uncommitted files violate the First Principle Of Release!\n#{uncommitted.join("\n")}" unless uncommitted.empty?
  fail "You are releasing from a local branch that does not track a remote!" unless Git.remote
end

#tag_release(tag) ⇒ Object

Add a tag reference in .git/refs/tags and push it to the remote if any. If a tag with the same name already exists it will get deleted (in both local and remote repositories).



452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/buildr/core/build.rb', line 452

def tag_release(tag)
  unless this_version == extract_version
    info "Committing buildfile with version number #{extract_version}"
    Git.commit File.basename(Buildr.application.buildfile.to_s), message
    Git.push if Git.remote
  end
  info "Tagging release #{tag}"
  Git.git 'tag', '-d', tag rescue nil
  Git.git 'push', Git.remote, ":refs/tags/#{tag}" rescue nil if Git.remote
  Git.git 'tag', '-a', tag, '-m', "[buildr] Cutting release #{tag}"
  Git.git 'push', Git.remote, 'tag', tag if Git.remote
end

#update_version_to_nextObject



465
466
467
468
469
470
# File 'lib/buildr/core/build.rb', line 465

def update_version_to_next
  super
  info "Current version is now #{extract_version}"
  Git.commit File.basename(Buildr.application.buildfile.to_s), message
  Git.push if Git.remote
end