houston-core 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +94 -69
  3. data/app/adapters/houston/adapters/deployment/engineyard.rb +4 -3
  4. data/app/adapters/houston/adapters/version_control/git_adapter.rb +36 -42
  5. data/app/adapters/houston/adapters/version_control/git_adapter/github_repo.rb +2 -2
  6. data/app/adapters/houston/adapters/version_control/git_adapter/remote_repo.rb +23 -11
  7. data/app/adapters/houston/adapters/version_control/git_adapter/repo.rb +18 -8
  8. data/app/adapters/houston/adapters/version_control/null_repo.rb +8 -0
  9. data/app/assets/javascripts/core/handlebars_helpers.coffee +3 -3
  10. data/app/assets/stylesheets/application/github_repos.scss +77 -0
  11. data/app/assets/stylesheets/application/navigation.scss +2 -0
  12. data/app/assets/stylesheets/application/pull_requests.scss +44 -58
  13. data/app/assets/stylesheets/core/avatars.scss +5 -0
  14. data/app/assets/stylesheets/core/colors.scss.erb +10 -7
  15. data/app/concerns/commit_synchronizer.rb +3 -0
  16. data/app/controllers/github/pulls_controller.rb +12 -0
  17. data/app/controllers/project_tests_controller.rb +3 -3
  18. data/app/controllers/projects_controller.rb +45 -1
  19. data/app/controllers/releases_controller.rb +42 -26
  20. data/app/helpers/application_helper.rb +8 -0
  21. data/app/helpers/avatar_helper.rb +2 -2
  22. data/app/helpers/commit_helper.rb +2 -2
  23. data/app/helpers/oembed_helper.rb +8 -0
  24. data/app/helpers/project_helper.rb +4 -5
  25. data/app/helpers/release_helper.rb +11 -0
  26. data/app/helpers/timeline_helper.rb +1 -1
  27. data/app/helpers/url_helper.rb +0 -18
  28. data/app/interactors/cache_key_dependencies.rb +28 -0
  29. data/app/jobs/sync_all_tickets_job.rb +1 -0
  30. data/app/mailers/view_mailer.rb +0 -1
  31. data/app/models/commit.rb +1 -1
  32. data/app/models/github/pull_request.rb +82 -26
  33. data/app/models/github/pull_request_event.rb +2 -2
  34. data/app/models/milestone.rb +1 -0
  35. data/app/models/project.rb +14 -0
  36. data/app/models/project_dependencies.rb +5 -3
  37. data/app/models/task.rb +1 -1
  38. data/app/models/user.rb +41 -0
  39. data/app/views/commits/show.html.erb +9 -1
  40. data/app/views/github/pulls/index.html.erb +102 -0
  41. data/app/views/project_notification/new_release.html.erb +6 -0
  42. data/app/views/project_tickets/index.xls.erb +0 -7
  43. data/app/views/projects/_form.html.erb +29 -17
  44. data/app/views/projects/index.html.erb +3 -3
  45. data/app/views/projects/new_from_github.html.erb +67 -0
  46. data/app/views/releases/_commits.html.erb +1 -1
  47. data/app/views/releases/show.html.erb +9 -0
  48. data/app/views/users/_form.html.erb +35 -19
  49. data/config/application.rb +12 -0
  50. data/config/initializers/mime_types.rb +1 -0
  51. data/config/routes.rb +17 -3
  52. data/db/migrate/20151201042126_require_projects_to_have_name_and_slug.rb +6 -0
  53. data/db/migrate/20151202005557_add_head_sha_to_projects.rb +24 -0
  54. data/db/migrate/20151202011812_require_projects_to_have_color.rb +13 -0
  55. data/db/migrate/20151205204922_require_project_slugs_to_be_unique.rb +5 -0
  56. data/db/migrate/20151205214647_add_avatar_url_to_pull_requests.rb +5 -0
  57. data/db/migrate/20151209004458_add_json_labels_to_pull_requests.rb +5 -0
  58. data/db/migrate/20151209030113_add_timestamps_to_pull_requests.rb +6 -0
  59. data/db/structure.sql +31 -5
  60. data/houston.gemspec +7 -7
  61. data/lib/configuration.rb +3 -2
  62. data/lib/houston/version.rb +1 -1
  63. data/lib/rack/oembed.rb +23 -0
  64. data/templates/new-instance/config/jobs/cache_key_dependencies.rb +3 -0
  65. data/templates/new-instance/config/triggers/tests/slack_when_analyzed.rb +1 -4
  66. data/templates/new-instance/config/triggers/tests/slack_when_completed.rb +1 -1
  67. data/templates/new-instance/lib/slack_helpers.rb +1 -1
  68. data/test/integration/ticket_tasks_api_test.rb +1 -1
  69. data/test/unit/adapters/git_adapter_test.rb +29 -8
  70. data/test/unit/adapters/version_control_adapters_api_test.rb +2 -0
  71. data/test/unit/controllers/hooks_controller_test.rb +4 -4
  72. data/test/unit/models/commit_test.rb +2 -2
  73. data/test/unit/models/project_test.rb +2 -2
  74. data/test/unit/models/pull_request_test.rb +9 -4
  75. data/test/unit/models/task_test.rb +1 -1
  76. data/test/unit/models/ticket_test.rb +1 -1
  77. metadata +31 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3406892d3fcfe0ad9866e9dd8a498ddcd9f289d0
4
- data.tar.gz: a211ccfa508c1ed3ce16de510e7f5339d8be2500
3
+ metadata.gz: ccdc8ca97e863eac07e91316e4df92a6058c0319
4
+ data.tar.gz: cf508ea2d4af78899f39fb4152dafb5a371bdd14
5
5
  SHA512:
6
- metadata.gz: 07845570a0d72d5477f0238c20b8d766b6543322ddcd504f94d066efa9b28751ea966943b80c0b461c4140a4e2a9ff079fced0bbf3374a80cad9bd86c4722390
7
- data.tar.gz: ba178a7479bb6657c39fd1ecacbb447644929c95bdb35ff66a7ccbf6cb9b76cd8bd39077ac906def21e5bd2e65b5756038722b7ca33e0d97391d919c77841ecd
6
+ metadata.gz: efad3f461cf426eae2346593caa7524680b1260cd417603df9ba057deb3ef427d342d40eaa84f2e631b0432976719f1681e83b67c167314ce3cafe486341acfd
7
+ data.tar.gz: 3e54190cf91f35922f34f5e21738d3ae4877e976316fa7e346bc6d8231644585c45f6554cdb47a038817e885b7ef6d690d74cddf21eba1f47ae6fc314fd86f68
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- houston-core (0.5.6)
4
+ houston-core (0.6.0)
5
5
  activerecord-import
6
6
  activerecord-pluck_in_batches
7
7
  addressable
@@ -10,10 +10,10 @@ PATH
10
10
  bundler
11
11
  cancan (~> 1.6.10)
12
12
  codeclimate-test-reporter (= 0.4.8)
13
- coffee-rails (~> 4.0.0)
14
- default_value_for (= 3.0.0.1)
15
- devise (~> 3.0.0)
16
- devise_invitable (~> 1.2.1)
13
+ coffee-rails (~> 4.1.0)
14
+ default_value_for (= 3.0.1)
15
+ devise (~> 3.5.0)
16
+ devise_invitable (~> 1.5.3)
17
17
  engineyard (~> 3.2.1)
18
18
  faraday (~> 0.8.10)
19
19
  faraday-http-cache (~> 1.2.2)
@@ -36,58 +36,65 @@ PATH
36
36
  premailer (~> 1.8.6)
37
37
  progressbar
38
38
  rack-utf8_sanitizer (~> 1.3.1)
39
- rails (~> 4.1.13)
39
+ rails (~> 4.2.5)
40
40
  redcarpet (~> 3.3.2)
41
41
  rufus-scheduler (~> 3.1.7)
42
42
  rugged (~> 0.23.3)
43
- sass-rails (~> 4.0.0)
43
+ sass-rails (~> 5.0)
44
44
  simplecov (~> 0.9.1)
45
45
  sprockets (~> 2.8)
46
46
  strongbox (~> 0.7.2)
47
47
  thor
48
48
  thread_safe (~> 0.3.5)
49
- uglifier (>= 1.3.0)
49
+ uglifier (>= 2.7.2)
50
50
  whenever (= 0.9.2)
51
51
 
52
52
  GEM
53
53
  remote: https://rubygems.org/
54
54
  specs:
55
- actionmailer (4.1.14)
56
- actionpack (= 4.1.14)
57
- actionview (= 4.1.14)
55
+ actionmailer (4.2.5)
56
+ actionpack (= 4.2.5)
57
+ actionview (= 4.2.5)
58
+ activejob (= 4.2.5)
58
59
  mail (~> 2.5, >= 2.5.4)
59
- actionpack (4.1.14)
60
- actionview (= 4.1.14)
61
- activesupport (= 4.1.14)
62
- rack (~> 1.5.2)
60
+ rails-dom-testing (~> 1.0, >= 1.0.5)
61
+ actionpack (4.2.5)
62
+ actionview (= 4.2.5)
63
+ activesupport (= 4.2.5)
64
+ rack (~> 1.6)
63
65
  rack-test (~> 0.6.2)
64
- actionview (4.1.14)
65
- activesupport (= 4.1.14)
66
+ rails-dom-testing (~> 1.0, >= 1.0.5)
67
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
68
+ actionview (4.2.5)
69
+ activesupport (= 4.2.5)
66
70
  builder (~> 3.1)
67
71
  erubis (~> 2.7.0)
68
- activemodel (4.1.14)
69
- activesupport (= 4.1.14)
72
+ rails-dom-testing (~> 1.0, >= 1.0.5)
73
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
74
+ activejob (4.2.5)
75
+ activesupport (= 4.2.5)
76
+ globalid (>= 0.3.0)
77
+ activemodel (4.2.5)
78
+ activesupport (= 4.2.5)
70
79
  builder (~> 3.1)
71
- activerecord (4.1.14)
72
- activemodel (= 4.1.14)
73
- activesupport (= 4.1.14)
74
- arel (~> 5.0.0)
80
+ activerecord (4.2.5)
81
+ activemodel (= 4.2.5)
82
+ activesupport (= 4.2.5)
83
+ arel (~> 6.0)
75
84
  activerecord-import (0.10.0)
76
85
  activerecord (>= 3.0)
77
86
  activerecord-pluck_in_batches (0.1.0)
78
87
  activerecord
79
- activesupport (4.1.14)
80
- i18n (~> 0.6, >= 0.6.9)
88
+ activesupport (4.2.5)
89
+ i18n (~> 0.7)
81
90
  json (~> 1.7, >= 1.7.7)
82
91
  minitest (~> 5.1)
83
- thread_safe (~> 0.1)
92
+ thread_safe (~> 0.3, >= 0.3.4)
84
93
  tzinfo (~> 1.1)
85
94
  addressable (2.3.8)
86
95
  ansi (1.5.0)
87
- arel (5.0.1.20140414130214)
96
+ arel (6.0.3)
88
97
  bcrypt (3.1.10)
89
- bcrypt-ruby (3.1.5)
90
- bcrypt (>= 3.1.3)
91
98
  boblail-unfuddle (0.7.0)
92
99
  activesupport
93
100
  builder
@@ -105,27 +112,29 @@ GEM
105
112
  codeclimate-test-reporter (0.4.8)
106
113
  simplecov (>= 0.7.1, < 1.0.0)
107
114
  coderay (1.1.0)
108
- coffee-rails (4.0.1)
115
+ coffee-rails (4.1.0)
109
116
  coffee-script (>= 2.2.0)
110
117
  railties (>= 4.0.0, < 5.0)
111
118
  coffee-script (2.4.1)
112
119
  coffee-script-source
113
120
  execjs
114
- coffee-script-source (1.9.1.1)
115
- crack (0.4.2)
121
+ coffee-script-source (1.10.0)
122
+ crack (0.4.3)
116
123
  safe_yaml (~> 1.0.0)
117
124
  css_parser (1.3.7)
118
125
  addressable
119
- default_value_for (3.0.0.1)
126
+ default_value_for (3.0.1)
120
127
  activerecord (>= 3.2.0, < 5.0)
121
- devise (3.0.4)
122
- bcrypt-ruby (~> 3.0)
128
+ devise (3.5.3)
129
+ bcrypt (~> 3.0)
123
130
  orm_adapter (~> 0.1)
124
131
  railties (>= 3.2.6, < 5)
132
+ responders
133
+ thread_safe (~> 0.1)
125
134
  warden (~> 1.2.3)
126
- devise_invitable (1.2.1)
135
+ devise_invitable (1.5.3)
127
136
  actionmailer (>= 3.2.6, < 5)
128
- devise (~> 3.0.0)
137
+ devise (>= 3.2.0)
129
138
  docile (1.1.5)
130
139
  domain_name (0.5.25)
131
140
  unf (>= 0.0.5, < 1.0.0)
@@ -157,18 +166,20 @@ GEM
157
166
  faraday-raise-errors (0.2.0)
158
167
  faraday
159
168
  gemoji (2.1.0)
169
+ globalid (0.3.6)
170
+ activesupport (>= 4.1.0)
160
171
  googlecharts (1.6.12)
161
172
  handlebars_assets (0.21.0)
162
173
  execjs (~> 2.0)
163
174
  multi_json (~> 1.0)
164
175
  sprockets (>= 2.0.0, < 4.0)
165
176
  tilt (~> 1.2)
166
- hashdiff (0.2.2)
177
+ hashdiff (0.2.3)
167
178
  highline (1.6.21)
168
179
  hike (1.2.3)
169
- houston-devise_ldap_authenticatable (0.7.0)
170
- devise (~> 3.0.0)
171
- net-ldap (~> 0.2)
180
+ houston-devise_ldap_authenticatable (0.7.1)
181
+ devise (>= 3.0.0)
182
+ net-ldap (~> 0.12.1)
172
183
  houston-oauth-plugin (0.5.1)
173
184
  multi_json
174
185
  oauth (~> 0.4.4)
@@ -187,13 +198,15 @@ GEM
187
198
  launchy (2.4.3)
188
199
  addressable (~> 2.3)
189
200
  libv8 (3.16.14.13)
201
+ loofah (2.0.3)
202
+ nokogiri (>= 1.5.9)
190
203
  mail (2.6.3)
191
204
  mime-types (>= 1.16, < 3)
192
205
  method_source (0.8.2)
193
- mime-types (2.6.2)
206
+ mime-types (2.99)
194
207
  mini_portile (0.6.2)
195
- minitest (5.8.1)
196
- minitest-reporters (1.1.4)
208
+ minitest (5.8.3)
209
+ minitest-reporters (1.1.7)
197
210
  ansi
198
211
  builder
199
212
  minitest (>= 5.0)
@@ -205,7 +218,7 @@ GEM
205
218
  multipart-post (1.2.0)
206
219
  neat-rails (0.1.0)
207
220
  nested_editor_for (0.1.0)
208
- net-ldap (0.12.0)
221
+ net-ldap (0.12.1)
209
222
  net-ssh (2.9.2)
210
223
  netrc (0.11.0)
211
224
  nokogiri (1.6.6.4)
@@ -219,12 +232,12 @@ GEM
219
232
  rack (~> 1.2)
220
233
  octokit (4.1.1)
221
234
  sawyer (~> 0.6.0, >= 0.5.3)
222
- oj (2.13.1)
223
- openxml-package (0.2.0)
235
+ oj (2.14.0)
236
+ openxml-package (0.2.2)
224
237
  nokogiri
225
238
  ox
226
239
  rubyzip (~> 1.1.0)
227
- openxml-xlsx (0.2.0)
240
+ openxml-xlsx (0.2.2)
228
241
  nokogiri
229
242
  openxml-package (>= 0.2.0)
230
243
  orm_adapter (0.5.0)
@@ -242,29 +255,40 @@ GEM
242
255
  coderay (~> 1.1.0)
243
256
  method_source (~> 0.8.1)
244
257
  slop (~> 3.4)
245
- rack (1.5.5)
258
+ rack (1.6.4)
246
259
  rack-test (0.6.3)
247
260
  rack (>= 1.0)
248
261
  rack-utf8_sanitizer (1.3.1)
249
262
  rack (~> 1.0)
250
- rails (4.1.14)
251
- actionmailer (= 4.1.14)
252
- actionpack (= 4.1.14)
253
- actionview (= 4.1.14)
254
- activemodel (= 4.1.14)
255
- activerecord (= 4.1.14)
256
- activesupport (= 4.1.14)
263
+ rails (4.2.5)
264
+ actionmailer (= 4.2.5)
265
+ actionpack (= 4.2.5)
266
+ actionview (= 4.2.5)
267
+ activejob (= 4.2.5)
268
+ activemodel (= 4.2.5)
269
+ activerecord (= 4.2.5)
270
+ activesupport (= 4.2.5)
257
271
  bundler (>= 1.3.0, < 2.0)
258
- railties (= 4.1.14)
259
- sprockets-rails (~> 2.0)
260
- railties (4.1.14)
261
- actionpack (= 4.1.14)
262
- activesupport (= 4.1.14)
272
+ railties (= 4.2.5)
273
+ sprockets-rails
274
+ rails-deprecated_sanitizer (1.0.3)
275
+ activesupport (>= 4.2.0.alpha)
276
+ rails-dom-testing (1.0.7)
277
+ activesupport (>= 4.2.0.beta, < 5.0)
278
+ nokogiri (~> 1.6.0)
279
+ rails-deprecated_sanitizer (>= 1.0.1)
280
+ rails-html-sanitizer (1.0.2)
281
+ loofah (~> 2.0)
282
+ railties (4.2.5)
283
+ actionpack (= 4.2.5)
284
+ activesupport (= 4.2.5)
263
285
  rake (>= 0.8.7)
264
286
  thor (>= 0.18.1, < 2.0)
265
287
  rake (10.4.2)
266
288
  redcarpet (3.3.3)
267
289
  ref (2.0.0)
290
+ responders (2.1.0)
291
+ railties (>= 4.2.0, < 5)
268
292
  rest-client (1.8.0)
269
293
  http-cookie (>= 1.0.2, < 2.0)
270
294
  mime-types (>= 1.16, < 3.0)
@@ -275,12 +299,13 @@ GEM
275
299
  rufus-scheduler (3.1.10)
276
300
  rugged (0.23.3)
277
301
  safe_yaml (1.0.4)
278
- sass (3.2.19)
279
- sass-rails (4.0.5)
302
+ sass (3.4.20)
303
+ sass-rails (5.0.4)
280
304
  railties (>= 4.0.0, < 5.0)
281
- sass (~> 3.2.2)
282
- sprockets (~> 2.8, < 3.0)
283
- sprockets-rails (~> 2.0)
305
+ sass (~> 3.1)
306
+ sprockets (>= 2.8, < 4.0)
307
+ sprockets-rails (>= 2.0, < 4.0)
308
+ tilt (>= 1.1, < 3)
284
309
  sawyer (0.6.0)
285
310
  addressable (~> 2.3.5)
286
311
  faraday (~> 0.8, < 0.10)
@@ -305,7 +330,7 @@ GEM
305
330
  sprockets (>= 2.8, < 4.0)
306
331
  strongbox (0.7.2)
307
332
  activerecord
308
- test_after_commit (0.4.1)
333
+ test_after_commit (0.4.2)
309
334
  activerecord (>= 3.2)
310
335
  therubyracer (0.12.2)
311
336
  libv8 (~> 3.16.14.0)
@@ -322,9 +347,9 @@ GEM
322
347
  unf (0.1.4)
323
348
  unf_ext
324
349
  unf_ext (0.0.7.1)
325
- warden (1.2.3)
350
+ warden (1.2.4)
326
351
  rack (>= 1.0)
327
- webmock (1.22.1)
352
+ webmock (1.22.3)
328
353
  addressable (>= 2.3.6)
329
354
  crack (>= 0.3.2)
330
355
  hashdiff
@@ -73,6 +73,10 @@ module Houston
73
73
 
74
74
  deployment.successful = runner.call(out, err)
75
75
 
76
+ Houston.try({max_tries: 5, ignore: true}, exceptions_wrapping(PG::ConnectionBad)) do
77
+ deploy.update_attributes!(completed_at: Time.now)
78
+ end
79
+
76
80
  rescue StandardError => e
77
81
  Houston.report_exception(e)
78
82
  deployment.err << "Error encountered during deploy.\n#{e.class} #{e}\n"
@@ -80,9 +84,6 @@ module Houston
80
84
 
81
85
  ensure
82
86
  deployment.finished
83
- Houston.try({max_tries: 5, ignore: true}, exceptions_wrapping(PG::ConnectionBad)) do
84
- deploy.update_attributes!(completed_at: Time.now)
85
- end
86
87
  end
87
88
 
88
89
  deployment.successful?
@@ -10,12 +10,16 @@ module Houston
10
10
  # ------------------------------------------------------------------------- #
11
11
 
12
12
  def errors_with_parameters(project, location)
13
- location = Addressable::URI.parse(location.to_s)
14
- connect_to_repo!(location, project.version_control_temp_path)
13
+ location = location.to_s
14
+ return ERROR_BLANK if location.blank?
15
+
16
+ if local_path? location
17
+ return ERROR_DOES_NOT_EXIST unless File.exists? location
18
+ else
19
+ return ERROR_CANT_CONNECT unless can_fetch? location
20
+ end
21
+
15
22
  {}
16
- rescue Rugged::RepositoryError, Rugged::OSError, Rugged::SshError
17
- Rails.logger.error "#{$!.class.name}: #{$!.message}\n #{$!.backtrace.take(7).join("\n ")}"
18
- { git_location: ["might not be right. Houston can't seem to connect to it."] }
19
23
  end
20
24
 
21
25
  def build(project, location)
@@ -23,17 +27,19 @@ module Houston
23
27
  end
24
28
 
25
29
  def connect(location, temp_path)
26
- location = Addressable::URI.parse(location.to_s)
30
+ location = location.to_s
27
31
  return Houston::Adapters::VersionControl::NullRepo if location.blank?
28
32
 
29
- connection = connect_to_repo! location, temp_path
33
+ if local_path? location
34
+ return Houston::Adapters::VersionControl::NullRepo unless File.exists? location
35
+
36
+ return self::Repo.new(location)
37
+ else
38
+ return Houston::Adapters::VersionControl::NullRepo unless File.exists?(temp_path) || can_fetch?(location)
30
39
 
31
- return self::Repo.new(connection) unless location.absolute?
32
- return self::GithubRepo.new(connection, location) if /github/ === location
33
- return self::RemoteRepo.new(connection, location)
34
- rescue Rugged::RepositoryError, Rugged::OSError, Rugged::SshError
35
- Rails.logger.warn "\e[33m[git_adapter] #{$!.class}: #{$!.message}\e[0m"
36
- Houston::Adapters::VersionControl::NullRepo
40
+ return self::GithubRepo.new(temp_path, location) if /github/ === location
41
+ return self::RemoteRepo.new(temp_path, location)
42
+ end
37
43
  end
38
44
 
39
45
  def parameters
@@ -44,28 +50,6 @@ module Houston
44
50
 
45
51
 
46
52
 
47
- def connect_to_repo!(repo_uri, temp_path)
48
- git_path = get_local_path_to_repo(repo_uri, temp_path.to_s)
49
- Rugged::Repository.new(git_path)
50
- end
51
-
52
- def get_local_path_to_repo(repo_uri, temp_path)
53
- if repo_uri.absolute?
54
- clone!(repo_uri, temp_path) unless File.exists?(temp_path)
55
- temp_path
56
- else
57
- repo_uri.to_s
58
- end
59
- end
60
-
61
- def clone!(origin_uri, local_path, async: false)
62
- if async
63
- Houston.async { _clone!(origin_uri, local_path, true) }
64
- else
65
- _clone!(origin_uri, local_path, false)
66
- end
67
- end
68
-
69
53
  def credentials
70
54
  Rugged::Credentials::SshKey.new(
71
55
  username: SSH_USERNAME,
@@ -77,18 +61,28 @@ module Houston
77
61
 
78
62
  private
79
63
 
80
- def _clone!(origin_uri, local_path, async)
81
- Houston.benchmark("[git:clone#{":async" if async}] #{origin_uri} => #{local_path}") do
82
- Rugged::Repository.clone_at origin_uri.to_s, local_path.to_s,
83
- credentials: GitAdapter.credentials,
84
- bare: true
85
- end
86
- end
64
+ ERROR_BLANK = {git_location: ["is blank"]}.freeze
65
+ ERROR_DOES_NOT_EXIST = {git_location: ["does not exist"]}.freeze
66
+ ERROR_CANT_CONNECT = {git_location: ["might not be right. Houston can't seem to connect to it."]}.freeze
87
67
 
88
68
  SSH_USERNAME = "git".freeze
89
69
  SSH_PRIVATEKEY = File.expand_path("~/.ssh/id_rsa").freeze
90
70
  SSH_PUBLICKEY = File.expand_path("~/.ssh/id_rsa.pub").freeze
91
71
 
72
+ def local_path?(location)
73
+ !Addressable::URI.parse(location.to_s).absolute?
74
+ end
75
+
76
+ def can_fetch?(url)
77
+ Houston.benchmark "[git_adapter] can_fetch?(#{url})" do
78
+ Dir.mktmpdir do |path|
79
+ repo = Rugged::Repository.init_at path, :bare
80
+ remote = repo.remotes.create_anonymous(url)
81
+ remote.check_connection(:fetch, credentials: GitAdapter.credentials)
82
+ end
83
+ end
84
+ end
85
+
92
86
  end
93
87
  end
94
88
  end