Permalink
Browse files

Added a "Git Config" command - currently supports Email and Name

  • Loading branch information...
1 parent 88ed4ae commit d28efbe0f9377892d6d7df78e4e0fe3efd599f0a @timcharper timcharper committed Apr 5, 2008
View
@@ -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>
@@ -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
@@ -0,0 +1,4 @@
+module ConfigHelper
+ def config_line
+ end
+end
@@ -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>
@@ -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
View
@@ -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>

0 comments on commit d28efbe

Please sign in to comment.