dreamcat4-braid 0.52 → 0.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/braid.gemspec +2 -2
  2. data/lib/braid/rspec_git.rb +154 -0
  3. metadata +2 -1
data/braid.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{braid}
3
- s.version = "0.52"
3
+ s.version = "0.53"
4
4
 
5
5
  s.specification_version = 2 if s.respond_to? :specification_version=
6
6
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.description = %q{A simple tool for tracking vendor branches in git.}
12
12
  s.email = %q{evil@che.lu}
13
13
  s.executables = ["braid"]
14
- s.files = ["bin/braid", "braid.gemspec", "lib/braid/command.rb", "lib/braid/commands/add.rb", "lib/braid/commands/diff.rb", "lib/braid/commands/remove.rb", "lib/braid/commands/setup.rb", "lib/braid/commands/update.rb", "lib/braid/config.rb", "lib/braid/mirror.rb", "lib/braid/operations.rb", "lib/braid.rb", "LICENSE", "Rakefile", "README.textile", "test/braid_test.rb", "test/config_test.rb", "test/fixtures/shiny/README", "test/fixtures/skit1/layouts/layout.liquid", "test/fixtures/skit1/preview.png", "test/fixtures/skit1.1/layouts/layout.liquid", "test/fixtures/skit1.2/layouts/layout.liquid", "test/integration/adding_test.rb", "test/integration/updating_test.rb", "test/integration_helper.rb", "test/mirror_test.rb", "test/operations_test.rb", "test/test_helper.rb"]
14
+ s.files = ["bin/braid", "braid.gemspec", "lib/braid/command.rb", "lib/braid/commands/add.rb", "lib/braid/commands/diff.rb", "lib/braid/commands/remove.rb", "lib/braid/commands/setup.rb", "lib/braid/commands/update.rb", "lib/braid/config.rb", "lib/braid/mirror.rb", "lib/braid/operations.rb", "lib/braid/rspec_git.rb", "lib/braid.rb", "LICENSE", "Rakefile", "README.textile", "test/braid_test.rb", "test/config_test.rb", "test/fixtures/shiny/README", "test/fixtures/skit1/layouts/layout.liquid", "test/fixtures/skit1/preview.png", "test/fixtures/skit1.1/layouts/layout.liquid", "test/fixtures/skit1.2/layouts/layout.liquid", "test/integration/adding_test.rb", "test/integration/updating_test.rb", "test/integration_helper.rb", "test/mirror_test.rb", "test/operations_test.rb", "test/test_helper.rb"]
15
15
  s.has_rdoc = false
16
16
  s.homepage = %q{http://evil.che.lu/projects/braid}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main"]
@@ -0,0 +1,154 @@
1
+ module RSpec
2
+ class Git
3
+
4
+ attr_reader :name, :path, :url
5
+
6
+ def initialize(name, path, url)
7
+ @name = name
8
+ @path = path
9
+ @url = url
10
+ end
11
+
12
+ def plugins_fetched?
13
+ submodules.all? {|s| File.directory?(s[:path]) }
14
+ end
15
+
16
+ def update(target)
17
+ check_for_clean_repos "Unable to update"
18
+
19
+ repos.each do |r|
20
+ if File.exist?(r[:path])
21
+ msg "** Updating #{r[:name]}"
22
+ # target = ENV['REMOTE'] ? "#{ENV['REMOTE']} master" : ""
23
+ unless system("cd #{r[:path]} && git pull --rebase #{target}")
24
+ msg "Error updating #{r[:name]}"
25
+ exit 1
26
+ end
27
+ else
28
+ msg "** Fetching #{r[:name]}"
29
+ system "git clone #{r[:url]} #{r[:path]}"
30
+ end
31
+ end
32
+ msg "*** all repos updated successfully ***"
33
+ end
34
+
35
+ def status
36
+ repos.each do |r|
37
+ msg "\n** #{r[:name]} status"
38
+ system "cd #{r[:path]} && git status"
39
+ end
40
+ end
41
+
42
+ def push
43
+ check_for_clean_repos "Unable to push"
44
+
45
+ repos.each do |r|
46
+ msg "** push #{r[:name]}"
47
+ unless system("cd #{r[:path]} && git push && git push --tags")
48
+ msg "Error pushing #{r[:name]}"
49
+ exit 1
50
+ end
51
+ end
52
+ msg "Successfully pushed changes to github"
53
+ end
54
+
55
+ def commit
56
+ if ENV['MESSAGE'].nil?
57
+ msg "You must pass a commit message. Try it again with:\n" +
58
+ "rake git:commit MESSAGE='commit message here'"
59
+ return
60
+ end
61
+
62
+ repos.each do |r|
63
+ output = `cd #{r[:path]} && git status`
64
+ unless output.include?('On branch master')
65
+ msg "*** #{r[:name]} is not on the master branch. Skipping"
66
+ next
67
+ end
68
+ msg "** Committing #{r[:name]}"
69
+ system "cd #{r[:path]} && git commit -a -m #{ENV['MESSAGE'].inspect}"
70
+ end
71
+ end
72
+
73
+ def hard_reset
74
+ repos.each do |r|
75
+ msg "\n** Resetting #{r[:name]}"
76
+ system "cd #{r[:path]} && git add . && git reset --hard"
77
+ end
78
+ msg
79
+ end
80
+
81
+ def add_remotes
82
+ if ENV['REPO_PREFIX'].nil? || ENV['NAME'].nil?
83
+ msg "You must pass a prefix and name. Try it again with (e.g.):\n" +
84
+ "rake git:add_remotes REPO_PREFIX='git://github.com/dchelimsky' NAME='dc'"
85
+ return
86
+ end
87
+
88
+ repos.each do |r|
89
+ system "cd #{r[:path]} && git remote add #{ENV['NAME']} #{r[:url]}"
90
+ end
91
+ end
92
+
93
+ def tag
94
+ if ENV['TAG'].nil?
95
+ msg "You must pass a tag. Try again like so:\n" +
96
+ " TAG=1.1.4 rake git:tag"
97
+ return
98
+ end
99
+ repos.each do |r|
100
+ system "cd #{r[:path]} && git tag #{ENV['TAG']}"
101
+ end
102
+ end
103
+
104
+ private
105
+ def check_for_clean_repos(message)
106
+ unless all_repos_clean?
107
+ msg "*** #{message} ***"
108
+ status
109
+ exit 1
110
+ end
111
+ end
112
+
113
+ def all_repos_clean?
114
+ repos.all? do |r|
115
+ !File.exist?(r[:path]) ||
116
+ (output = `cd #{r[:path]} && git status`;
117
+ output.include?('On branch master') &&
118
+ !output.include?('Changes to be committed:') &&
119
+ !output.include?('Changed but not updated:'))
120
+ end
121
+ end
122
+
123
+ def repos
124
+ # [submodules, superproject].flatten
125
+ [ {:name => @name, :path => @path, :url => @url} ]
126
+ end
127
+
128
+ # def superproject
129
+ # {:name => "rspec-dev", :path => ".",
130
+ # :url => "#{url_prefix}/rspec-dev.git"}
131
+ # end
132
+
133
+ # def submodules
134
+ # [
135
+ # {:name => "TextMate Bundle", :path => 'RSpec.tmbundle',
136
+ # :url => "#{url_prefix}/rspec-tmbundle.git" },
137
+ # {:name => "rspec", :path => 'example_rails_app/vendor/plugins/rspec',
138
+ # :url => "#{url_prefix}/rspec.git"},
139
+ # {:name => "rspec-rails", :path => 'example_rails_app/vendor/plugins/rspec-rails',
140
+ # :url => "#{url_prefix}/rspec-rails.git"}
141
+ # ]
142
+ # end
143
+
144
+ def url_prefix
145
+ if ENV["COMMITTER"]
146
+ "git@github.com:dreamcat4"
147
+ elsif ENV["REPO_PREFIX"]
148
+ ENV["REPO_PREFIX"]
149
+ else
150
+ "git://github.com/dreamcat4"
151
+ end
152
+ end
153
+ end
154
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dreamcat4-braid
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.52"
4
+ version: "0.53"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristi Balan
@@ -53,6 +53,7 @@ files:
53
53
  - lib/braid/config.rb
54
54
  - lib/braid/mirror.rb
55
55
  - lib/braid/operations.rb
56
+ - lib/braid/rspec_git.rb
56
57
  - lib/braid.rb
57
58
  - LICENSE
58
59
  - Rakefile