Class: StiDeploy::Git
- Inherits:
-
Object
- Object
- StiDeploy::Git
- Defined in:
- lib/sti_deploy/git.rb,
lib/sti_deploy/git/merge.rb,
lib/sti_deploy/git/commit.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#deploy_type ⇒ Object
readonly
Returns the value of attribute deploy_type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
- .add_version ⇒ Object
- .checkout(branch: 'master') ⇒ Object
- .commit(message: '') ⇒ Object
- .merge(branch: 'master') ⇒ Object
- .pull(branch: 'master', remote: 'origin') ⇒ Object
- .push(branch: 'master', remote: 'origin') ⇒ Object
- .push_tags ⇒ Object
- .tag(version: '', message: '') ⇒ Object
Instance Method Summary collapse
- #commit!(message) ⇒ Object
- #commit_branch ⇒ Object
- #commit_merge_and_tag!(message) ⇒ Object
-
#initialize(version, deploy_type) ⇒ Git
constructor
A new instance of Git.
- #merge! ⇒ Object
-
#merge_branches ⇒ Object
Can be more than one branch, example: merge staging to production and hotfix, to synchronize production with hotfix and staging.
- #tag!(message) ⇒ Object
Constructor Details
#initialize(version, deploy_type) ⇒ Git
Returns a new instance of Git.
41 42 43 44 |
# File 'lib/sti_deploy/git.rb', line 41 def initialize(version, deploy_type) @version = version @deploy_type = deploy_type end |
Instance Attribute Details
#deploy_type ⇒ Object (readonly)
Returns the value of attribute deploy_type.
5 6 7 |
# File 'lib/sti_deploy/git.rb', line 5 def deploy_type @deploy_type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/sti_deploy/git.rb', line 5 def version @version end |
Class Method Details
.add_version ⇒ Object
8 9 10 |
# File 'lib/sti_deploy/git.rb', line 8 def add_version `git add #{Configuration.version_path}` end |
.checkout(branch: 'master') ⇒ Object
16 17 18 |
# File 'lib/sti_deploy/git.rb', line 16 def checkout(branch: 'master') `git checkout #{branch}`.to_i.zero? end |
.commit(message: '') ⇒ Object
12 13 14 |
# File 'lib/sti_deploy/git.rb', line 12 def commit(message: '') `git commit -m "#{.tr('"', '\"')}"`.to_i.zero? end |
.merge(branch: 'master') ⇒ Object
20 21 22 |
# File 'lib/sti_deploy/git.rb', line 20 def merge(branch: 'master') `git merge #{branch}`.to_i.zero? end |
.pull(branch: 'master', remote: 'origin') ⇒ Object
28 29 30 |
# File 'lib/sti_deploy/git.rb', line 28 def pull(branch: 'master', remote: 'origin') `git pull #{remote} #{branch}`.to_i.zero? end |
.push(branch: 'master', remote: 'origin') ⇒ Object
32 33 34 |
# File 'lib/sti_deploy/git.rb', line 32 def push(branch: 'master', remote: 'origin') `git push #{remote} #{branch}`.to_i.zero? end |
.push_tags ⇒ Object
36 37 38 |
# File 'lib/sti_deploy/git.rb', line 36 def `git push --tags`.to_i.zero? end |
.tag(version: '', message: '') ⇒ Object
24 25 26 |
# File 'lib/sti_deploy/git.rb', line 24 def tag(version: '', message: '') `git tag -a v#{version.to_s} -m "#{.tr('"', '\"')}"`.to_i.zero? end |
Instance Method Details
#commit!(message) ⇒ Object
52 53 54 |
# File 'lib/sti_deploy/git.rb', line 52 def commit!() Git::Commit.new(commit_branch, ).commit! end |
#commit_branch ⇒ Object
68 69 70 |
# File 'lib/sti_deploy/git.rb', line 68 def commit_branch Configuration.commit_branch(deploy_type) end |
#commit_merge_and_tag!(message) ⇒ Object
46 47 48 49 50 |
# File 'lib/sti_deploy/git.rb', line 46 def commit_merge_and_tag!() commit!() merge! tag!() end |
#merge! ⇒ Object
56 57 58 59 60 |
# File 'lib/sti_deploy/git.rb', line 56 def merge! merge_branches.each do |target_branch| Git::Merge.new(commit_branch, target_branch).merge! end end |
#merge_branches ⇒ Object
Can be more than one branch, example: merge staging to production and hotfix, to synchronize production with hotfix and staging.
74 75 76 |
# File 'lib/sti_deploy/git.rb', line 74 def merge_branches Array(Configuration.merge_branch(deploy_type)) end |