Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
Added a "Git Config" command - currently supports Email and Name
Browse files Browse the repository at this point in the history
  • Loading branch information
timcharper committed Apr 5, 2008
1 parent 88ed4ae commit d28efbe
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Commands/Config.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
dispatch :controller =&gt; "config", :action =&gt; "index"</string>
<key>input</key>
<string>none</string>
<key>name</key>
<string>Config…</string>
<key>output</key>
<string>showAsHTML</string>
<key>uuid</key>
<string>794C7EF9-B0A5-4B27-90BD-000837237B85</string>
</dict>
</plist>
11 changes: 11 additions & 0 deletions Support/app/controllers/config_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ConfigController < ApplicationController
include ConfigHelper
def index
render "index"
end

def set
value = params[:value]
git.config[(params[:scope] || "local"), params[:key]] = params[:value]
end
end
4 changes: 4 additions & 0 deletions Support/app/helpers/config_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ConfigHelper
def config_line
end
end
19 changes: 19 additions & 0 deletions Support/app/views/config/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Config</h1>
<form>
<table>
<thead>
<tr>
<th>Global Config</th>
<!-- <th>Local Config Config</th>-->
</tr>
</thead>
<tbody>
<tr>
<td>
Name: <%= content_tag :input, :type => "text", :value => git.config[:global, "user.name"], :onchange => "dispatch({controller: 'config', action: 'set', scope: 'global', key: 'user.name', value: $F(this)})" %><br/>
Email: <%= content_tag :input, :type => "text", :value => git.config[:global, "user.email"], :onchange => "dispatch({controller: 'config', action: 'set', scope: 'global', key: 'user.email', value: $F(this)})" %><br/>
</td>
</tr>
</tbody>
</table>
</form>
24 changes: 24 additions & 0 deletions Support/spec/controllers/config_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe ConfigController do
include SpecHelpers
include Parsers

before(:each) do
@controller = ConfigController.singleton_new
@git = Git.singleton_new
end

describe "when setting values" do
it "should default to local" do
@git.config.should_receive(:[]=).with("local", "user.name", "My Name")
capture_output { dispatch(:controller => "config", :action => "set", :key => "user.name", :value => "My Name" )}
end

it "should allow setting of global variables" do
@git.config.should_receive(:[]=).with("global", "user.name", "My Name")
capture_output { dispatch(:controller => "config", :action => "set", :scope => "global", :key => "user.name", :value => "My Name" )}
end
end

end
2 changes: 2 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
<string>CFB9BB9D-4F47-47DA-819B-58F0B29FA560</string>
<string>1CCC4394-A243-4E78-A720-B2DA1BC37DC0</string>
<string>556EF65D-C59B-4A15-BA4A-D5D87C2695A0</string>
<string>3F77F0FC-F476-4B83-92D1-77D854A9D64D</string>
<string>794C7EF9-B0A5-4B27-90BD-000837237B85</string>
</array>
<key>uuid</key>
<string>EADD4718-EE11-4ABF-A7E6-13351FB3799D</string>
Expand Down

0 comments on commit d28efbe

Please sign in to comment.