git_wit 0.0.4.pre → 0.0.4.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -21,9 +21,7 @@ That's it - your app is hosting git repositories. Create a repositories folder,
21
21
  init a bare repo, and push to it:
22
22
 
23
23
  ```console
24
- $ git init
25
- $ git add .
26
- $ git commit -m "That was easy"
24
+ $ git init; git add .; git commit -m "That was easy"
27
25
  $ mkdir repositories # Hosted repos folder
28
26
  $ git init --bare repositories/example.git # Example bare repo
29
27
  $ git remote add origin http://localhost:3000/example.git
@@ -35,13 +33,13 @@ HTTPS? That works too:
35
33
  ```console
36
34
  $ sudo echo "pre-loading sudo so we can background tunnels in a moment"
37
35
  $ rails g git_wit:install authenticate authorize_read authorize_write -f
38
- $ gem install tunnels
36
+ $ echo 'gem "tunnels"' >> Gemfile; bundle
39
37
  $ sudo tunnels 443 3000 & # or `rvmsudo tunnels...` if using RVM
40
38
  $ git remote add https https://localhost/example.git
41
39
  $ GIT_SSL_NO_VERIFY=1 git push https master:https-master # Trust yourself
42
40
  ```
43
41
 
44
- Still not impressed? Try SSH (OS X only currently):
42
+ Still not impressed? Try SSH:
45
43
 
46
44
  ```console
47
45
  $ rails g git_wit:install authenticate authorize_read authorize_write ssh_user:git_wit -f
@@ -13,15 +13,16 @@ module GitWit
13
13
  end
14
14
 
15
15
  def create_user
16
- @home = dscl_user ssh_user, home
16
+ @home = dscl_user ssh_user, home if mac?
17
+ @home = etc_user ssh_user, home if linux?
17
18
  end
18
19
 
19
20
  def create_group
20
- dscl_group ssh_group
21
+ dscl_group ssh_group if mac?
21
22
  end
22
23
 
23
24
  def add_user_to_group
24
- dscl_group_membership ssh_user, ssh_group
25
+ dscl_group_membership ssh_user, ssh_group if mac?
25
26
  end
26
27
 
27
28
  def build_home
@@ -33,6 +34,14 @@ module GitWit
33
34
  end
34
35
 
35
36
  protected
37
+ def mac?
38
+ !!(RbConfig::CONFIG['host_os'] =~ /^darwin/)
39
+ end
40
+
41
+ def linux?
42
+ !!(RbConfig::CONFIG['host_os'] =~ /^linux/)
43
+ end
44
+
36
45
  def ssh_user
37
46
  GitWit.ssh_user
38
47
  end
@@ -4,6 +4,9 @@
4
4
  Defaults:<%= ssh_user %> env_keep += "SSH_ORIGINAL_COMMAND GEM_HOME GEM_PATH"
5
5
  Defaults:<%= ssh_user %> env_keep += "BUNDLE_GEMFILE RAILS_ENV RAILS_ROOT"
6
6
 
7
+ # The following line is required for many linux distros, but not OS X:
8
+ <%= '# ' if mac? %>Defaults:<%= ssh_user %> secure_path="<%= git_wit_bindir %>:<%= RbConfig::CONFIG['bindir'] %>:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
9
+
7
10
  # Allow <%= rails_user %> to run any command as <%= ssh_user %>
8
11
  <%= rails_user %> ALL=(<%= ssh_user %>) NOPASSWD:ALL
9
12
 
@@ -0,0 +1,38 @@
1
+ module GitWit::Actions::Etc
2
+ class Base < Thor::Actions::EmptyDirectory
3
+
4
+ attr_reader :base, :type, :name
5
+
6
+ def initialize(base, type, name, config = {})
7
+ @base, @type, @name = base, type, name
8
+ @config = {verbose: true}.merge config
9
+ end
10
+
11
+ def invoke!
12
+ invoke_with_conflict_check do
13
+ create
14
+ end
15
+ end
16
+
17
+ def revoke!
18
+ say_status :remove, :red
19
+ destroy if !pretend? && exists?
20
+ end
21
+
22
+ def exists?
23
+ etc_exists?
24
+ end
25
+
26
+ protected
27
+ def etc_exists?
28
+ file = type == :user ? "passwd" : "group"
29
+ `grep '#{name}:x:' /etc/#{file}`
30
+ $?.success?
31
+ end
32
+
33
+ def say_status(status, color, msg = nil)
34
+ msg ||= "#{type} #{name}"
35
+ base.shell.say_status status, msg, color if config[:verbose]
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ module GitWit::Actions::Etc
2
+ class User < Base
3
+ def initialize(base, name, home, config = {})
4
+ super base, :user, name, config
5
+ @home = home
6
+ end
7
+
8
+ def invoke!
9
+ invoke_with_conflict_check do
10
+ create
11
+ end
12
+ home
13
+ end
14
+
15
+ def revoke!
16
+ say_status :remove, :red
17
+ destroy if !pretend? && exists?
18
+ home
19
+ end
20
+
21
+ protected
22
+ def home
23
+ @home || "/home/#{name}"
24
+ end
25
+
26
+ def create
27
+ `sudo useradd -M -U -r -s '/bin/bash' -d '#{home}' '#{name}'`
28
+ raise Thor::Error, "Could not create user #{name}" unless $?.success?
29
+ end
30
+
31
+ def destroy
32
+ `sudo userdel -r '#{name}'`
33
+ raise Thor::Error, "Could not destroy user #{name}" unless $?.success?
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ module GitWit::Actions::Etc
2
+ module Actions
3
+ def etc_user(name, home, config = {})
4
+ action User.new(self, name, home, config)
5
+ end
6
+ end
7
+ end
@@ -20,7 +20,7 @@ module GitWit::Actions::Ssh
20
20
  end
21
21
 
22
22
  def exists?
23
- `sudo grep '#{sentinel}' /etc/sudoers &>/dev/null`
23
+ `sudo grep '#{sentinel}' /etc/sudoers 2>/dev/null`
24
24
  $?.success?
25
25
  end
26
26
 
@@ -1,5 +1,8 @@
1
1
  module GitWit; module Actions; end; end
2
2
 
3
+ require "git_wit/actions/etc"
4
+ require "git_wit/actions/etc/base"
5
+ require "git_wit/actions/etc/user"
3
6
  require "git_wit/actions/ssh"
4
7
  require "git_wit/actions/ssh/home"
5
8
  require "git_wit/actions/ssh/sudoers"
@@ -11,6 +14,7 @@ require "git_wit/actions/dscl/group_membership"
11
14
 
12
15
  module GitWit
13
16
  module Actions
17
+ include Etc::Actions
14
18
  include Dscl::Actions
15
19
  include Ssh::Actions
16
20
  end
@@ -3,6 +3,7 @@ module GitWit
3
3
  module Debug
4
4
  def debug
5
5
  boot_app
6
+ require "pp"
6
7
  debug_banner "Start"
7
8
  pp "ENVIRONMENT:", ENV
8
9
  GitWit.configure { |c| pp "GitWit Config:", c }
@@ -1,4 +1,4 @@
1
1
  module GitWit
2
2
  # Public: Rubygems compatible version number String.
3
- VERSION = "0.0.4.pre"
3
+ VERSION = "0.0.4.pre2"
4
4
  end
data/lib/git_wit.rb CHANGED
@@ -3,7 +3,6 @@ require "active_support/configurable"
3
3
  require "git_wit/engine"
4
4
  require "git_wit/errors"
5
5
  require "git_wit/auth"
6
- require "git_wit/shell"
7
6
  require "git_wit/authorized_keys"
8
7
  require "git_wit/authorized_keys/key"
9
8
  require "git_wit/authorized_keys/file"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'edit_json.rb' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('json', 'edit_json.rb')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'minitar' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('archive-tar-minitar', 'minitar')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'prettify_json.rb' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('json', 'prettify_json.rb')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'vagrant' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('vagrant', 'vagrant')
@@ -1677,3 +1677,292 @@ Started GET "/example.git/info/refs?service=git-receive-pack" for 127.0.0.1 at 2
1677
1677
 
1678
1678
 
1679
1679
  Started POST "/example.git/git-receive-pack" for 127.0.0.1 at 2013-02-23 15:26:05 -0600
1680
+ Connecting to database specified by database.yml
1681
+
1682
+
1683
+ Started GET "/" for 127.0.0.1 at 2013-02-23 16:30:39 -0600
1684
+ Processing by RepositoriesController#index as HTML
1685
+ Completed 500 Internal Server Error in 28ms
1686
+
1687
+ ActiveRecord::StatementInvalid - Could not find table 'users':
1688
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
1689
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
1690
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
1691
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `columns'
1692
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:243:in `column_defaults'
1693
+ (gem) activerecord-3.2.12/lib/active_record/base.rb:482:in `initialize'
1694
+ app/models/ability.rb:5:in `initialize'
1695
+ (gem) cancan-1.6.9/lib/cancan/controller_additions.rb:352:in `current_ability'
1696
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:207:in `current_ability'
1697
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:77:in `load_collection?'
1698
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:33:in `load_resource'
1699
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
1700
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
1701
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:418:in `_run__2174323338086652337__process_action__4209835832759253270__callbacks'
1702
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1703
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
1704
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1705
+ (gem) actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
1706
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
1707
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
1708
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
1709
+ (gem) activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
1710
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
1711
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
1712
+ (gem) actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
1713
+ (gem) activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
1714
+ (gem) actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
1715
+ (gem) actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
1716
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:203:in `dispatch'
1717
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
1718
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:246:in `block in action'
1719
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
1720
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in `call'
1721
+ (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
1722
+ (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
1723
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
1724
+ (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
1725
+ (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
1726
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
1727
+ (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
1728
+ (gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
1729
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
1730
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
1731
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
1732
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
1733
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
1734
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
1735
+ (gem) activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
1736
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
1737
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
1738
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `_run__2934629329071937135__call__3062669868321674216__callbacks'
1739
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1740
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
1741
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1742
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
1743
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/reloader.rb:65:in `call'
1744
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
1745
+ (gem) better_errors-0.6.0/lib/better_errors/middleware.rb:71:in `protected_app_call'
1746
+ (gem) better_errors-0.6.0/lib/better_errors/middleware.rb:66:in `better_errors_call'
1747
+ (gem) better_errors-0.6.0/lib/better_errors/middleware.rb:41:in `call'
1748
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
1749
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
1750
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:32:in `call_app'
1751
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `block in call'
1752
+ (gem) activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in `tagged'
1753
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `call'
1754
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in `call'
1755
+ (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
1756
+ (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
1757
+ (gem) activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
1758
+ (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
1759
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:62:in `call'
1760
+ (gem) railties-3.2.12/lib/rails/engine.rb:479:in `call'
1761
+ (gem) railties-3.2.12/lib/rails/application.rb:223:in `call'
1762
+ (gem) railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
1763
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:147:in `handle'
1764
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:99:in `rescue in block (2 levels) in start'
1765
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:96:in `block (2 levels) in start'
1766
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:86:in `block in start'
1767
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:66:in `start'
1768
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:13:in `run'
1769
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:4:in `<main>'
1770
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:0:in `<main>'
1771
+
1772
+
1773
+
1774
+ Started POST "/__better_errors/70222691415840/variables" for 127.0.0.1 at 2013-02-23 16:30:40 -0600
1775
+ Connecting to database specified by database.yml
1776
+ GitWit SSH cmd: git shell -c git-receive-pack '/Users/xdissent/Code/git_wit/test/dummy/repositories/example.git'
1777
+ Connecting to database specified by database.yml
1778
+ GitWit SSH cmd: git shell -c git-receive-pack '/Users/xdissent/Code/git_wit/test/dummy/repositories/example.git'
1779
+ Connecting to database specified by database.yml
1780
+
1781
+
1782
+ Started GET "/" for 127.0.0.1 at 2013-02-23 17:35:40 -0600
1783
+ Processing by RepositoriesController#index as HTML
1784
+ Completed 500 Internal Server Error in 82ms
1785
+
1786
+ ActiveRecord::StatementInvalid - Could not find table 'users':
1787
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
1788
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
1789
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
1790
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `columns'
1791
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:243:in `column_defaults'
1792
+ (gem) activerecord-3.2.12/lib/active_record/base.rb:482:in `initialize'
1793
+ app/models/ability.rb:5:in `initialize'
1794
+ (gem) cancan-1.6.9/lib/cancan/controller_additions.rb:352:in `current_ability'
1795
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:207:in `current_ability'
1796
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:77:in `load_collection?'
1797
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:33:in `load_resource'
1798
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
1799
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
1800
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:418:in `_run__239347504280997447__process_action__3870065149297230727__callbacks'
1801
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1802
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
1803
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1804
+ (gem) actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
1805
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
1806
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
1807
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
1808
+ (gem) activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
1809
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
1810
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
1811
+ (gem) actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
1812
+ (gem) activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
1813
+ (gem) actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
1814
+ (gem) actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
1815
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:203:in `dispatch'
1816
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
1817
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:246:in `block in action'
1818
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
1819
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in `call'
1820
+ (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
1821
+ (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
1822
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
1823
+ (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
1824
+ (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
1825
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
1826
+ (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
1827
+ (gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
1828
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
1829
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
1830
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
1831
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
1832
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
1833
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
1834
+ (gem) activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
1835
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
1836
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
1837
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `_run__2045829604109974730__call__1408478891629556635__callbacks'
1838
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1839
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
1840
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1841
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
1842
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/reloader.rb:65:in `call'
1843
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
1844
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:84:in `protected_app_call'
1845
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:79:in `better_errors_call'
1846
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:56:in `call'
1847
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
1848
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
1849
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:32:in `call_app'
1850
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `block in call'
1851
+ (gem) activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in `tagged'
1852
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `call'
1853
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in `call'
1854
+ (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
1855
+ (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
1856
+ (gem) activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
1857
+ (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
1858
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:62:in `call'
1859
+ (gem) railties-3.2.12/lib/rails/engine.rb:479:in `call'
1860
+ (gem) railties-3.2.12/lib/rails/application.rb:223:in `call'
1861
+ (gem) railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
1862
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:147:in `handle'
1863
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:99:in `rescue in block (2 levels) in start'
1864
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:96:in `block (2 levels) in start'
1865
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:86:in `block in start'
1866
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:66:in `start'
1867
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:13:in `run'
1868
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:4:in `<main>'
1869
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:0:in `<main>'
1870
+
1871
+
1872
+
1873
+ Started POST "/__better_errors/70157365567060/variables" for 127.0.0.1 at 2013-02-23 17:35:40 -0600
1874
+ Connecting to database specified by database.yml
1875
+
1876
+
1877
+ Started GET "/" for 127.0.0.1 at 2013-02-23 19:34:37 -0600
1878
+ Processing by RepositoriesController#index as HTML
1879
+ Completed 500 Internal Server Error in 64ms
1880
+
1881
+ ActiveRecord::StatementInvalid - Could not find table 'users':
1882
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
1883
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
1884
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
1885
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `columns'
1886
+ (gem) activerecord-3.2.12/lib/active_record/model_schema.rb:243:in `column_defaults'
1887
+ (gem) activerecord-3.2.12/lib/active_record/base.rb:482:in `initialize'
1888
+ app/models/ability.rb:5:in `initialize'
1889
+ (gem) cancan-1.6.9/lib/cancan/controller_additions.rb:352:in `current_ability'
1890
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:207:in `current_ability'
1891
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:77:in `load_collection?'
1892
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:33:in `load_resource'
1893
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
1894
+ (gem) cancan-1.6.9/lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
1895
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:418:in `_run__3035164196489960414__process_action__77161949566051706__callbacks'
1896
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1897
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
1898
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1899
+ (gem) actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
1900
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
1901
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
1902
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
1903
+ (gem) activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
1904
+ (gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
1905
+ (gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
1906
+ (gem) actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
1907
+ (gem) activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
1908
+ (gem) actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
1909
+ (gem) actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
1910
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:203:in `dispatch'
1911
+ (gem) actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
1912
+ (gem) actionpack-3.2.12/lib/action_controller/metal.rb:246:in `block in action'
1913
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
1914
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in `call'
1915
+ (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
1916
+ (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
1917
+ (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
1918
+ (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
1919
+ (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
1920
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
1921
+ (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
1922
+ (gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
1923
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
1924
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
1925
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
1926
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
1927
+ (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
1928
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
1929
+ (gem) activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
1930
+ (gem) activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
1931
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
1932
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `_run__4171490266094897651__call__732453632278865349__callbacks'
1933
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
1934
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
1935
+ (gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
1936
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
1937
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/reloader.rb:65:in `call'
1938
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
1939
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:84:in `protected_app_call'
1940
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:79:in `better_errors_call'
1941
+ (gem) better_errors-0.7.0/lib/better_errors/middleware.rb:56:in `call'
1942
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
1943
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
1944
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:32:in `call_app'
1945
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `block in call'
1946
+ (gem) activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in `tagged'
1947
+ (gem) railties-3.2.12/lib/rails/rack/logger.rb:16:in `call'
1948
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in `call'
1949
+ (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
1950
+ (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
1951
+ (gem) activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
1952
+ (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
1953
+ (gem) actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:62:in `call'
1954
+ (gem) railties-3.2.12/lib/rails/engine.rb:479:in `call'
1955
+ (gem) railties-3.2.12/lib/rails/application.rb:223:in `call'
1956
+ (gem) railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
1957
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:147:in `handle'
1958
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:99:in `rescue in block (2 levels) in start'
1959
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:96:in `block (2 levels) in start'
1960
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:86:in `block in start'
1961
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:66:in `start'
1962
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/server.rb:13:in `run'
1963
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:4:in `<main>'
1964
+ /Users/xdissent/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/bin/nack_worker:0:in `<main>'
1965
+
1966
+
1967
+
1968
+ Started POST "/__better_errors/70268531667100/variables" for 127.0.0.1 at 2013-02-23 19:34:37 -0600
@@ -157,3 +157,93 @@ Connecting to database specified by database.yml
157
157
   (0.0ms) rollback transaction
158
158
   (0.0ms) begin transaction
159
159
   (0.0ms) rollback transaction
160
+ Connecting to database specified by database.yml
161
+  (0.4ms) begin transaction
162
+  (0.0ms) rollback transaction
163
+  (0.0ms) begin transaction
164
+  (0.0ms) rollback transaction
165
+  (0.0ms) begin transaction
166
+  (0.0ms) rollback transaction
167
+  (0.0ms) begin transaction
168
+  (0.0ms) rollback transaction
169
+  (0.0ms) begin transaction
170
+  (0.0ms) rollback transaction
171
+  (0.0ms) begin transaction
172
+  (0.0ms) rollback transaction
173
+  (0.0ms) begin transaction
174
+  (0.0ms) rollback transaction
175
+  (0.0ms) begin transaction
176
+  (0.0ms) rollback transaction
177
+  (0.0ms) begin transaction
178
+  (0.1ms) rollback transaction
179
+  (0.1ms) begin transaction
180
+  (0.1ms) rollback transaction
181
+  (0.1ms) begin transaction
182
+  (0.1ms) rollback transaction
183
+  (0.0ms) begin transaction
184
+  (0.1ms) rollback transaction
185
+  (0.0ms) begin transaction
186
+  (0.1ms) rollback transaction
187
+  (0.1ms) begin transaction
188
+  (0.0ms) rollback transaction
189
+  (0.0ms) begin transaction
190
+  (0.0ms) rollback transaction
191
+  (0.0ms) begin transaction
192
+  (0.0ms) rollback transaction
193
+  (0.0ms) begin transaction
194
+  (0.1ms) rollback transaction
195
+  (0.1ms) begin transaction
196
+  (0.0ms) rollback transaction
197
+  (0.1ms) begin transaction
198
+  (0.1ms) rollback transaction
199
+  (0.0ms) begin transaction
200
+  (0.0ms) rollback transaction
201
+  (0.0ms) begin transaction
202
+  (0.0ms) rollback transaction
203
+  (0.0ms) begin transaction
204
+  (0.0ms) rollback transaction
205
+  (0.0ms) begin transaction
206
+  (0.0ms) rollback transaction
207
+  (0.0ms) begin transaction
208
+  (0.0ms) rollback transaction
209
+  (0.0ms) begin transaction
210
+  (0.0ms) rollback transaction
211
+  (0.0ms) begin transaction
212
+  (0.0ms) rollback transaction
213
+ Connecting to database specified by database.yml
214
+  (0.4ms) begin transaction
215
+  (0.0ms) rollback transaction
216
+  (0.0ms) begin transaction
217
+  (0.0ms) rollback transaction
218
+  (0.0ms) begin transaction
219
+  (0.0ms) rollback transaction
220
+  (0.0ms) begin transaction
221
+  (0.0ms) rollback transaction
222
+  (0.0ms) begin transaction
223
+  (0.0ms) rollback transaction
224
+  (0.0ms) begin transaction
225
+  (0.0ms) rollback transaction
226
+  (0.0ms) begin transaction
227
+  (0.0ms) rollback transaction
228
+  (0.0ms) begin transaction
229
+  (0.0ms) rollback transaction
230
+  (0.0ms) begin transaction
231
+  (0.1ms) rollback transaction
232
+  (0.1ms) begin transaction
233
+  (0.1ms) rollback transaction
234
+  (0.0ms) begin transaction
235
+  (0.1ms) rollback transaction
236
+  (0.1ms) begin transaction
237
+  (0.1ms) rollback transaction
238
+  (0.1ms) begin transaction
239
+  (0.1ms) rollback transaction
240
+  (0.1ms) begin transaction
241
+  (0.1ms) rollback transaction
242
+  (0.0ms) begin transaction
243
+  (0.0ms) rollback transaction
244
+  (0.0ms) begin transaction
245
+  (0.0ms) rollback transaction
246
+  (0.0ms) begin transaction
247
+  (0.0ms) rollback transaction
248
+  (0.0ms) begin transaction
249
+  (0.0ms) rollback transaction
@@ -0,0 +1,89 @@
1
+ require 'test_helper'
2
+
3
+ class CliTest < ActiveSupport::TestCase
4
+ # def setup
5
+ # GitWit.stash_config
6
+ # GitWit.default_config!
7
+ # end
8
+
9
+ # def teardown
10
+ # GitWit.restore_config
11
+ # end
12
+
13
+ # test "should use RAILS_ROOT env variable if given" do
14
+ # old_root = ENV.delete "RAILS_ROOT"
15
+
16
+ # ENV["RAILS_ROOT"] = "/example/rails/app"
17
+ # assert_equal ENV["RAILS_ROOT"], GitWit::Shell.rails_root
18
+
19
+ # ENV["RAILS_ROOT"] = old_root
20
+ # end
21
+
22
+ # test "should use BUNDLE_GEMFILE env variable if no rails root" do
23
+ # old_root = ENV.delete "RAILS_ROOT"
24
+ # old_bundle = ENV.delete "BUNDLE_GEMFILE"
25
+
26
+ # ENV["BUNDLE_GEMFILE"] = "/another/rails/app/Gemfile"
27
+ # assert_equal "/another/rails/app", GitWit::Shell.rails_root
28
+
29
+ # ENV["RAILS_ROOT"] = old_root
30
+ # ENV["BUNDLE_GEMFILE"] = old_bundle
31
+ # end
32
+
33
+ # test "should use current directory if no RAILS_ROOT or BUNDLE_GEMFILE given" do
34
+ # old_root = ENV.delete "RAILS_ROOT"
35
+ # old_bundle = ENV.delete "BUNDLE_GEMFILE"
36
+
37
+ # tmp_dir = Rails.root.join("tmp").to_s
38
+ # assert Dir.exist?(tmp_dir)
39
+ # Dir.chdir(tmp_dir) do
40
+ # assert_equal tmp_dir, GitWit::Shell.rails_root
41
+ # end
42
+
43
+ # ENV["RAILS_ROOT"] = old_root
44
+ # ENV["BUNDLE_GEMFILE"] = old_bundle
45
+ # end
46
+
47
+ # test "should deduce the app user from file ownership of rails root" do
48
+ # old_root = ENV.delete "RAILS_ROOT"
49
+
50
+ # ENV["RAILS_ROOT"] = Rails.root.to_s
51
+ # assert_equal Process.uid, GitWit::Shell.app_user
52
+
53
+ # ENV["RAILS_ROOT"] = old_root
54
+ # end
55
+
56
+ # test "should know if it's running as a given user" do
57
+ # assert GitWit::Shell.running_as?(Process.uid)
58
+ # end
59
+
60
+ # test "should parse git commands into command and repository path" do
61
+ # ENV["SSH_ORIGINAL_COMMAND"] = "#{GitWit::Shell::SHELL_COMMANDS.first} 'example.git'"
62
+ # cmd_repo = GitWit::Shell.parse_ssh_original_command
63
+ # assert_equal 2, cmd_repo.length
64
+ # assert_equal GitWit::Shell::SHELL_COMMANDS.first, cmd_repo.first
65
+ # assert_equal "example.git", cmd_repo.last
66
+ # ENV.delete "SSH_ORIGINAL_COMMAND"
67
+ # end
68
+
69
+ # test "should authenticate by only confirming that a user exists" do
70
+ # GitWit.configure { |c| c.user_for_authentication = ->(username) { "xxxx" } }
71
+ # GitWit.configure { |c| c.authenticate = ->(user, password) { raise "tried auth" } }
72
+ # assert_nothing_raised do
73
+ # assert_equal "xxxx", GitWit::Shell.authenticate("example")
74
+ # end
75
+ # GitWit.configure { |c| c.user_for_authentication = ->(username) { nil } }
76
+ # assert_nothing_raised do
77
+ # assert_nil GitWit::Shell.authenticate("example")
78
+ # end
79
+ # end
80
+
81
+ # test "should authorize read/write based on git command given" do
82
+ # GitWit.configure { |c| c.authorize_write = ->(user, repository) { user == "w" } }
83
+ # GitWit.configure { |c| c.authorize_read = ->(user, repository) { user == "r" } }
84
+ # assert GitWit::Shell.authorize("git-receive-pack", "w", "example.git")
85
+ # assert !GitWit::Shell.authorize("git-receive-pack", "r", "example.git")
86
+ # assert !GitWit::Shell.authorize("git-upload-pack", "w", "example.git")
87
+ # assert GitWit::Shell.authorize("git-upload-pack", "r", "example.git")
88
+ # end
89
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_wit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre
4
+ version: 0.0.4.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -84,6 +84,9 @@ files:
84
84
  - lib/git_wit/actions/dscl/group_membership.rb
85
85
  - lib/git_wit/actions/dscl/user.rb
86
86
  - lib/git_wit/actions/dscl.rb
87
+ - lib/git_wit/actions/etc/base.rb
88
+ - lib/git_wit/actions/etc/user.rb
89
+ - lib/git_wit/actions/etc.rb
87
90
  - lib/git_wit/actions/ssh/home.rb
88
91
  - lib/git_wit/actions/ssh/sudoers.rb
89
92
  - lib/git_wit/actions/ssh.rb
@@ -98,7 +101,6 @@ files:
98
101
  - lib/git_wit/commands/util.rb
99
102
  - lib/git_wit/engine.rb
100
103
  - lib/git_wit/errors.rb
101
- - lib/git_wit/shell.rb
102
104
  - lib/git_wit/version.rb
103
105
  - lib/git_wit.rb
104
106
  - lib/tasks/git_wit.rake
@@ -147,11 +149,14 @@ files:
147
149
  - test/dummy/app/views/repositories/new.html.erb
148
150
  - test/dummy/app/views/repositories/show.html.erb
149
151
  - test/dummy/bin/coderay
152
+ - test/dummy/bin/edit_json.rb
150
153
  - test/dummy/bin/erubis
151
154
  - test/dummy/bin/git_wit
152
155
  - test/dummy/bin/htmldiff
153
156
  - test/dummy/bin/ldiff
157
+ - test/dummy/bin/minitar
154
158
  - test/dummy/bin/posix-spawn-benchmark
159
+ - test/dummy/bin/prettify_json.rb
155
160
  - test/dummy/bin/pry
156
161
  - test/dummy/bin/rackup
157
162
  - test/dummy/bin/rails
@@ -164,6 +169,7 @@ files:
164
169
  - test/dummy/bin/tilt
165
170
  - test/dummy/bin/tt
166
171
  - test/dummy/bin/tunnels
172
+ - test/dummy/bin/vagrant
167
173
  - test/dummy/config/application.rb
168
174
  - test/dummy/config/boot.rb
169
175
  - test/dummy/config/database.yml
@@ -212,7 +218,6 @@ files:
212
218
  - test/dummy/test/unit/public_key_test.rb
213
219
  - test/dummy/test/unit/repository_test.rb
214
220
  - test/dummy/test/unit/user_test.rb
215
- - test/dummy/tmp/pids/server.pid
216
221
  - test/dummy/tmp/restart.txt
217
222
  - test/functional/git_wit/git_controller_test.rb
218
223
  - test/git_wit_test.rb
@@ -220,8 +225,8 @@ files:
220
225
  - test/test_helper.rb
221
226
  - test/unit/auth_test.rb
222
227
  - test/unit/authorized_keys_test.rb
228
+ - test/unit/cli_test.rb
223
229
  - test/unit/config_test.rb
224
- - test/unit/shell_test.rb
225
230
  - bin/git_wit
226
231
  homepage: http://xdissent.github.com/git_wit/
227
232
  licenses: []
@@ -237,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
242
  version: '0'
238
243
  segments:
239
244
  - 0
240
- hash: -3774003407888240297
245
+ hash: -3246049142049628021
241
246
  required_rubygems_version: !ruby/object:Gem::Requirement
242
247
  none: false
243
248
  requirements:
@@ -293,11 +298,14 @@ test_files:
293
298
  - test/dummy/app/views/repositories/new.html.erb
294
299
  - test/dummy/app/views/repositories/show.html.erb
295
300
  - test/dummy/bin/coderay
301
+ - test/dummy/bin/edit_json.rb
296
302
  - test/dummy/bin/erubis
297
303
  - test/dummy/bin/git_wit
298
304
  - test/dummy/bin/htmldiff
299
305
  - test/dummy/bin/ldiff
306
+ - test/dummy/bin/minitar
300
307
  - test/dummy/bin/posix-spawn-benchmark
308
+ - test/dummy/bin/prettify_json.rb
301
309
  - test/dummy/bin/pry
302
310
  - test/dummy/bin/rackup
303
311
  - test/dummy/bin/rails
@@ -310,6 +318,7 @@ test_files:
310
318
  - test/dummy/bin/tilt
311
319
  - test/dummy/bin/tt
312
320
  - test/dummy/bin/tunnels
321
+ - test/dummy/bin/vagrant
313
322
  - test/dummy/config/application.rb
314
323
  - test/dummy/config/boot.rb
315
324
  - test/dummy/config/database.yml
@@ -358,7 +367,6 @@ test_files:
358
367
  - test/dummy/test/unit/public_key_test.rb
359
368
  - test/dummy/test/unit/repository_test.rb
360
369
  - test/dummy/test/unit/user_test.rb
361
- - test/dummy/tmp/pids/server.pid
362
370
  - test/dummy/tmp/restart.txt
363
371
  - test/functional/git_wit/git_controller_test.rb
364
372
  - test/git_wit_test.rb
@@ -366,5 +374,5 @@ test_files:
366
374
  - test/test_helper.rb
367
375
  - test/unit/auth_test.rb
368
376
  - test/unit/authorized_keys_test.rb
377
+ - test/unit/cli_test.rb
369
378
  - test/unit/config_test.rb
370
- - test/unit/shell_test.rb
data/lib/git_wit/shell.rb DELETED
@@ -1,115 +0,0 @@
1
- module GitWit
2
- module Shell
3
- SHELL_COMMANDS = %w(git-upload-pack git-receive-pack git-upload-archive)
4
-
5
- def self.run
6
- exec_with_sudo!
7
- return run_debug if debug?
8
- boot_app
9
- command, repository = parse_ssh_original_command
10
- user = authenticate! ARGV[0]
11
- authorize! command, user, repository
12
-
13
- repo_path = File.expand_path File.join(GitWit.repositories_path, repository)
14
- cmd = ["git", "shell", "-c", "#{command} '#{repo_path}'"]
15
- Rails.logger.info "GitWit SSH command: #{cmd.join " "}"
16
- exec *cmd
17
- end
18
-
19
- def self.exec_with_sudo!(user = app_user)
20
- return if running_as?(user)
21
- Dir.chdir rails_root
22
- ENV["TERM"] = "dumb"
23
- cmd = ["sudo", "-u", "##{app_user}", $PROGRAM_NAME, *ARGV]
24
- exec *cmd
25
- end
26
-
27
- def self.debug?
28
- ARGV.include? "--debug"
29
- end
30
-
31
- def self.running_as?(user)
32
- Process.uid == user
33
- end
34
-
35
- def self.app_user
36
- File.stat(rails_root).uid
37
- end
38
-
39
- def self.rails_root
40
- return File.expand_path(ENV["RAILS_ROOT"]) if ENV["RAILS_ROOT"]
41
- return File.expand_path("..", ENV["BUNDLE_GEMFILE"]) if ENV["BUNDLE_GEMFILE"]
42
- Dir.pwd
43
- end
44
-
45
- def self.boot_app
46
- require File.expand_path File.join(rails_root, "config/environment")
47
- end
48
-
49
- def self.parse_ssh_original_command
50
- /^(?<cmd>git-[^\s]+)\s+'(?<repository>[^']+\.git)'/ =~ ENV["SSH_ORIGINAL_COMMAND"]
51
- unless SHELL_COMMANDS.include? cmd
52
- abort "Unknown command: #{ENV["SSH_ORIGINAL_COMMAND"]}"
53
- end
54
- [cmd, repository]
55
- end
56
-
57
- def self.authenticate(username)
58
- GitWit.user_for_authentication username
59
- end
60
-
61
- def self.authenticate!(username)
62
- user = authenticate username
63
- abort "Anonymous access denied" if user.nil?
64
- user
65
- end
66
-
67
- def self.authorize(command, user, repository)
68
- op = command == "git-receive-pack" ? :write : :read
69
- GitWit.authorize op, user, repository
70
- end
71
-
72
- def self.authorize!(command, user, repository)
73
- abort "Unauthorized" unless authorize command, user, repository
74
- end
75
-
76
- def self.run_debug
77
- require "pp"
78
- puts "*** GitWit DEBUG ***\n\n"
79
- puts "ENVIRONMENT:"
80
- pp ENV
81
- puts "\n*** GitWit DEBUG ***\n"
82
- end
83
- end
84
-
85
- def self.run_shell_test(quiet = true)
86
- success = false
87
- Dir.mktmpdir do |ssh|
88
- user = "git_wit_shell_test"
89
- key_file = File.join ssh, "id_rsa"
90
- pub_key_file = "#{key_file}.pub"
91
-
92
- cmd = %(ssh-keygen -q -t rsa -C "#{user}" -f "#{key_file}" -N "")
93
- puts "Running #{cmd}" unless quiet
94
- `#{cmd}`
95
-
96
- pub_key = File.open(pub_key_file) { |f| f.read }
97
- debug_key = AuthorizedKeys::Key.shell_key_for_username user, pub_key, true
98
- authorized_keys_file.add debug_key
99
- puts "Added key: #{debug_key}" unless quiet
100
-
101
- cmd = %(SSH_AUTH_SOCK="" ssh -i "#{key_file}" #{GitWit.ssh_user}@localhost test 123)
102
- puts "Running #{cmd}" unless quiet
103
- out = `#{cmd}`
104
- puts out unless quiet
105
- success = $?.success?
106
- if success
107
- puts "Success" unless quiet
108
- else
109
- puts "ERROR!" unless quiet
110
- end
111
- authorized_keys_file.remove debug_key
112
- end
113
- success
114
- end
115
- end
@@ -1 +0,0 @@
1
- 5431
@@ -1,89 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ShellTest < ActiveSupport::TestCase
4
- def setup
5
- GitWit.stash_config
6
- GitWit.default_config!
7
- end
8
-
9
- def teardown
10
- GitWit.restore_config
11
- end
12
-
13
- test "should use RAILS_ROOT env variable if given" do
14
- old_root = ENV.delete "RAILS_ROOT"
15
-
16
- ENV["RAILS_ROOT"] = "/example/rails/app"
17
- assert_equal ENV["RAILS_ROOT"], GitWit::Shell.rails_root
18
-
19
- ENV["RAILS_ROOT"] = old_root
20
- end
21
-
22
- test "should use BUNDLE_GEMFILE env variable if no rails root" do
23
- old_root = ENV.delete "RAILS_ROOT"
24
- old_bundle = ENV.delete "BUNDLE_GEMFILE"
25
-
26
- ENV["BUNDLE_GEMFILE"] = "/another/rails/app/Gemfile"
27
- assert_equal "/another/rails/app", GitWit::Shell.rails_root
28
-
29
- ENV["RAILS_ROOT"] = old_root
30
- ENV["BUNDLE_GEMFILE"] = old_bundle
31
- end
32
-
33
- test "should use current directory if no RAILS_ROOT or BUNDLE_GEMFILE given" do
34
- old_root = ENV.delete "RAILS_ROOT"
35
- old_bundle = ENV.delete "BUNDLE_GEMFILE"
36
-
37
- tmp_dir = Rails.root.join("tmp").to_s
38
- assert Dir.exist?(tmp_dir)
39
- Dir.chdir(tmp_dir) do
40
- assert_equal tmp_dir, GitWit::Shell.rails_root
41
- end
42
-
43
- ENV["RAILS_ROOT"] = old_root
44
- ENV["BUNDLE_GEMFILE"] = old_bundle
45
- end
46
-
47
- test "should deduce the app user from file ownership of rails root" do
48
- old_root = ENV.delete "RAILS_ROOT"
49
-
50
- ENV["RAILS_ROOT"] = Rails.root.to_s
51
- assert_equal Process.uid, GitWit::Shell.app_user
52
-
53
- ENV["RAILS_ROOT"] = old_root
54
- end
55
-
56
- test "should know if it's running as a given user" do
57
- assert GitWit::Shell.running_as?(Process.uid)
58
- end
59
-
60
- test "should parse git commands into command and repository path" do
61
- ENV["SSH_ORIGINAL_COMMAND"] = "#{GitWit::Shell::SHELL_COMMANDS.first} 'example.git'"
62
- cmd_repo = GitWit::Shell.parse_ssh_original_command
63
- assert_equal 2, cmd_repo.length
64
- assert_equal GitWit::Shell::SHELL_COMMANDS.first, cmd_repo.first
65
- assert_equal "example.git", cmd_repo.last
66
- ENV.delete "SSH_ORIGINAL_COMMAND"
67
- end
68
-
69
- test "should authenticate by only confirming that a user exists" do
70
- GitWit.configure { |c| c.user_for_authentication = ->(username) { "xxxx" } }
71
- GitWit.configure { |c| c.authenticate = ->(user, password) { raise "tried auth" } }
72
- assert_nothing_raised do
73
- assert_equal "xxxx", GitWit::Shell.authenticate("example")
74
- end
75
- GitWit.configure { |c| c.user_for_authentication = ->(username) { nil } }
76
- assert_nothing_raised do
77
- assert_nil GitWit::Shell.authenticate("example")
78
- end
79
- end
80
-
81
- test "should authorize read/write based on git command given" do
82
- GitWit.configure { |c| c.authorize_write = ->(user, repository) { user == "w" } }
83
- GitWit.configure { |c| c.authorize_read = ->(user, repository) { user == "r" } }
84
- assert GitWit::Shell.authorize("git-receive-pack", "w", "example.git")
85
- assert !GitWit::Shell.authorize("git-receive-pack", "r", "example.git")
86
- assert !GitWit::Shell.authorize("git-upload-pack", "w", "example.git")
87
- assert GitWit::Shell.authorize("git-upload-pack", "r", "example.git")
88
- end
89
- end