Class: Pod::Command::Push::Tag
- Inherits:
-
Pod::Command::Push
- Object
- Pod::Command
- Pod::Command::Push
- Pod::Command::Push::Tag
- Extended by:
- Executable
- Defined in:
- lib/pod/command/push-tag.rb
Class Method Summary collapse
Instance Method Summary collapse
- #commit_then_push(name) ⇒ Object
-
#initialize(argv) ⇒ Tag
constructor
A new instance of Tag.
- #modify_podspec(path, version) ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Tag
Returns a new instance of Tag.
24 25 26 27 28 29 30 31 |
# File 'lib/pod/command/push-tag.rb', line 24 def initialize(argv) @tag_on_change = argv.flag?('tag-on-change', false) @stop_on_exists = argv.flag?('stop-on-exists', false) @push_remote = argv.flag?('push-remote', false) @tag_version = argv.shift_argument @current_repo_dir = '' super end |
Class Method Details
.options ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pod/command/push-tag.rb', line 16 def self. [ ['--push-remote', 'Perform the step of pushing REPO to its remote'], ['--stop-on-exists', 'Stop running when tag is existed'], ['--tag-on-change', 'Just push tag when podspec is changed'], ].concat(super) end |
Instance Method Details
#commit_then_push(name) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pod/command/push-tag.rb', line 64 def commit_then_push(name) = "[#{name}] Bump version #{@tag_version}" podspec_name = "#{name}.podspec" # only commit if modified if pod_repo_git('status', '--porcelain').include?(podspec_name) pod_repo_git('add', '*.podspec') pod_repo_git('commit', '--no-verify', '-m', ) push_pod_repo(name) unless !@push_remote pod_repo_git('tag', '-a', @tag_version, '-m', ) push_tag_repo elsif !@tag_on_change check_repo_status(name, @current_repo_dir) update_repo(name, @current_repo_dir) pod_repo_git('tag', '-a', @tag_version, '-m', ) push_tag_repo else UI.puts " - [No change] #{name}: #{@tag_version}" end end |
#modify_podspec(path, version) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/pod/command/push-tag.rb', line 87 def modify_podspec(path, version) unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/ UI.puts "s.version: not found" return end unless File.exist?path UI.puts "Podspec file not found" return end File.open(path, "r+") do |f| s = "" f.each_line do |line| if line.to_s =~ /s\.version\s*=\s*"(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})"/ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match| version.to_s end end if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match| version.to_s end end s += line end File.open(path, "w+") do |f| f.write(s) end end end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pod/command/push-tag.rb', line 43 def run podspec_files.each do |spec_file| spec = Pod::Specification.from_file(spec_file) @tag_version = spec.version.to_s unless !@tag_version.nil? @current_repo_dir = Pathname(spec_file).dirname # check_repo_status(spec.name, Pathname(spec_file).dirname) # update_repo(spec.name, Pathname(spec_file).dirname) exists_tag = pod_repo_git('tag').include?(@tag_version) if exists_tag && @stop_on_exists raise Informative, "#{spec.name}: tag #{@tag_version} already exists" end UI.puts "#{spec.name}: tag #{@tag_version} already exists".red unless !exists_tag commit_then_push(spec.name) unless exists_tag end end |
#validate! ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/pod/command/push-tag.rb', line 33 def validate! super # help! 'A bump version is required.' unless @tag_version # unless @tag_version # raise Informative, # "A tag version is required." \ # '`pod push tag 0.1.0`.' # end end |