gitsu 0.0.1 → 0.0.2
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/.travis.yml +9 -0
- data/README.md +8 -4
- data/Rakefile +30 -2
- data/TODO +6 -2
- data/gitsu.gemspec +10 -1
- data/lib/gitsu.rb +1 -0
- data/lib/gitsu/git.rb +4 -2
- data/lib/gitsu/version.rb +48 -1
- data/spec/gitsu/git_spec.rb +7 -0
- data/spec/gitsu/version_spec.rb +56 -0
- data/spec/spec_helper.rb +2 -0
- metadata +72 -4
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Gitsu
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/drrb/gitsu)
|
4
|
+
[](https://coveralls.io/r/drrb/gitsu)
|
5
|
+
[](https://codeclimate.com/github/drrb/gitsu)
|
6
|
+
|
7
|
+
Gitsu helps to manage your Git users, by making it easy to switch
|
4
8
|
between users.
|
5
9
|
|
6
10
|
## Installation
|
@@ -9,7 +13,7 @@ between users.
|
|
9
13
|
|
10
14
|
## Usage
|
11
15
|
|
12
|
-
|
16
|
+
Gitsu is intended to be used from the command line, through Git.
|
13
17
|
|
14
18
|
To switch the configured Git user:
|
15
19
|
|
@@ -17,7 +21,7 @@ To switch the configured Git user:
|
|
17
21
|
|
18
22
|
Switched local user to John Galt <jgalt@tcmc.com>
|
19
23
|
|
20
|
-
To make it easier to switch users, tell
|
24
|
+
To make it easier to switch users, tell Gitsu about some users.
|
21
25
|
|
22
26
|
$ git su --add "John Galt <jgalt@tcmc.com>"
|
23
27
|
$ git su --add "Raphe Rackstraw <rack@hp.royalnavy.mod.uk>"
|
data/Rakefile
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
-
|
1
|
+
lib_path = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
|
3
|
+
require 'gitsu'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'cucumber/rake/task'
|
2
7
|
|
3
|
-
|
8
|
+
Cucumber::Rake::Task.new(:features)
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
|
11
|
+
task :default => [:spec, :features]
|
12
|
+
|
13
|
+
task :push_release => [:spec, :features] do
|
14
|
+
git = GitSu::Git.new(GitSu::Shell.new)
|
15
|
+
version = GitSu::Version.prompt($stdin, $stdout, "Enter the version to release", GitSu::Version.current)
|
16
|
+
next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.next_minor)
|
17
|
+
|
18
|
+
puts "Releasing #{version} and preparing for #{next_version}"
|
19
|
+
|
20
|
+
update_version(version)
|
21
|
+
git.commit("lib/gitsu/version.rb", "Preparing for release #{version}")
|
22
|
+
# TODO: check if this works as a symbol, otherwise just use string
|
23
|
+
#Rake::Task["release"].invoke
|
24
|
+
Rake::Task[:release].invoke
|
25
|
+
update_version(next_version)
|
26
|
+
git.commit("lib/gitsu/version.rb", "Preparing for next development iteration")
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_version(new_version)
|
30
|
+
system(%q[sed -i '' -E 's/VERSION = ".*"/VERSION = "] + new_version.to_s + %q["/' lib/gitsu/version.rb])
|
31
|
+
end
|
data/TODO
CHANGED
@@ -3,8 +3,12 @@ Features
|
|
3
3
|
Make colors configurable because people like that stuff
|
4
4
|
Support multiple users at once for pairing
|
5
5
|
|
6
|
+
Tasks
|
7
|
+
--------
|
8
|
+
Check for changes (and abort if you find them) during release
|
9
|
+
|
6
10
|
Bugs
|
7
|
-
|
11
|
+
--------
|
8
12
|
|
9
13
|
Tests
|
10
|
-
|
14
|
+
--------
|
data/gitsu.gemspec
CHANGED
@@ -9,11 +9,20 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.authors = ["drrb"]
|
10
10
|
gem.email = ["drrb@github.com"]
|
11
11
|
gem.description = %q{Manage your Git users}
|
12
|
-
gem.summary =
|
12
|
+
gem.summary = <<-EOF
|
13
|
+
Gitsu allows you to quickly configure and switch between Git users, for
|
14
|
+
different projects and contexts
|
15
|
+
EOF
|
13
16
|
gem.homepage = "http://drrb.github.com/gitsu"
|
14
17
|
|
15
18
|
gem.files = `git ls-files`.split($/)
|
16
19
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
21
|
gem.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# Dependencies
|
24
|
+
gem.add_development_dependency('coveralls')
|
25
|
+
gem.add_development_dependency('rake')
|
26
|
+
gem.add_development_dependency('rspec')
|
27
|
+
gem.add_development_dependency('cucumber')
|
19
28
|
end
|
data/lib/gitsu.rb
CHANGED
data/lib/gitsu/git.rb
CHANGED
@@ -108,11 +108,13 @@ module GitSu
|
|
108
108
|
def render_user(scope)
|
109
109
|
render selected_user(scope)
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
|
+
def commit(file, message)
|
113
|
+
@shell.execute("git commit #{file} --message='#{message}'")
|
114
|
+
end
|
112
115
|
end
|
113
116
|
|
114
117
|
class CachingGit < Git
|
115
|
-
|
116
118
|
def get_color(color_name)
|
117
119
|
@colors ||= {}
|
118
120
|
#TODO: what if it's an invalid color?
|
data/lib/gitsu/version.rb
CHANGED
@@ -1,3 +1,50 @@
|
|
1
1
|
module GitSu
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.0.2"
|
3
|
+
|
4
|
+
class Version
|
5
|
+
class ParseError < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
REGEX = /(\d+)\.(\d+).(\d+)/
|
9
|
+
def self.parse(string)
|
10
|
+
raise ParseError, "Couldn't parse string '#{string}' as version" unless REGEX =~ string
|
11
|
+
parts = REGEX.match(string)[1..3].map {|e| e.to_i }
|
12
|
+
Version.new(*parts)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.current
|
16
|
+
Version.parse(VERSION)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.prompt(input, output, prompt, default)
|
20
|
+
output.print "#{prompt} [#{default}]: "
|
21
|
+
value = input.gets.strip
|
22
|
+
if value.empty?
|
23
|
+
default
|
24
|
+
else
|
25
|
+
Version.parse value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_reader :major, :minor, :patch
|
30
|
+
def initialize(major, minor, patch)
|
31
|
+
@major, @minor, @patch = major, minor, patch
|
32
|
+
end
|
33
|
+
|
34
|
+
def next_minor
|
35
|
+
Version.new(@major, @minor + 1, @patch)
|
36
|
+
end
|
37
|
+
|
38
|
+
def ==(other)
|
39
|
+
eql? other
|
40
|
+
end
|
41
|
+
|
42
|
+
def eql?(other)
|
43
|
+
major = other.major && minor == other.minor && patch == other.patch
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
"#{major}.#{minor}.#{patch}"
|
48
|
+
end
|
49
|
+
end
|
3
50
|
end
|
data/spec/gitsu/git_spec.rb
CHANGED
@@ -185,5 +185,12 @@ module GitSu
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
|
+
|
189
|
+
describe "#commit" do
|
190
|
+
it "commits a file to the repository with the specified message" do
|
191
|
+
shell.should_receive(:execute).with("git commit file.dat --message='Committing changes'")
|
192
|
+
git.commit("file.dat", "Committing changes")
|
193
|
+
end
|
194
|
+
end
|
188
195
|
end
|
189
196
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module GitSu
|
4
|
+
describe Version do
|
5
|
+
describe "#parse" do
|
6
|
+
it "parses a version string" do
|
7
|
+
version = Version.parse("1.23.456")
|
8
|
+
version.major.should be 1
|
9
|
+
version.minor.should be 23
|
10
|
+
version.patch.should be 456
|
11
|
+
end
|
12
|
+
context "when the input is invalid" do
|
13
|
+
it "raises an exception" do
|
14
|
+
expect {Version.parse "x.x.x"}.to raise_error Version::ParseError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#prompt" do
|
20
|
+
let(:input) { double('input') }
|
21
|
+
let(:output) { double('output') }
|
22
|
+
let(:default) { Version.parse("1.2.3") }
|
23
|
+
|
24
|
+
it "prompts the user to input a version" do
|
25
|
+
output.should_receive(:print).with "Enter version [1.2.3]: "
|
26
|
+
input.should_receive(:gets).and_return "4.5.6"
|
27
|
+
version = Version.prompt(input, output, "Enter version", default)
|
28
|
+
version.should == Version.parse("4.5.6")
|
29
|
+
end
|
30
|
+
context "when no version is provided by user" do
|
31
|
+
it "returns the default value" do
|
32
|
+
output.should_receive(:print).with "Enter version [1.2.3]: "
|
33
|
+
input.should_receive(:gets).and_return ""
|
34
|
+
version = Version.prompt(input, output, "Enter version", default)
|
35
|
+
version.should == Version.parse("1.2.3")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#current" do
|
41
|
+
it "returns the current version" do
|
42
|
+
Version.parse(VERSION).should == Version.current
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#next_minor" do
|
47
|
+
it "increments the minor version by 1" do
|
48
|
+
version = Version.parse("1.2.3")
|
49
|
+
next_version = version.next_minor
|
50
|
+
next_version.major.should be 1
|
51
|
+
next_version.minor.should be 3
|
52
|
+
next_version.patch.should be 3
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,72 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coveralls
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: cucumber
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
14
78
|
description: Manage your Git users
|
15
79
|
email:
|
16
80
|
- drrb@github.com
|
@@ -21,6 +85,7 @@ extensions: []
|
|
21
85
|
extra_rdoc_files: []
|
22
86
|
files:
|
23
87
|
- .gitignore
|
88
|
+
- .travis.yml
|
24
89
|
- Gemfile
|
25
90
|
- LICENSE.txt
|
26
91
|
- README.md
|
@@ -59,6 +124,7 @@ files:
|
|
59
124
|
- spec/gitsu/switcher_spec.rb
|
60
125
|
- spec/gitsu/user_list_spec.rb
|
61
126
|
- spec/gitsu/user_spec.rb
|
127
|
+
- spec/gitsu/version_spec.rb
|
62
128
|
- spec/spec_helper.rb
|
63
129
|
homepage: http://drrb.github.com/gitsu
|
64
130
|
licenses: []
|
@@ -83,7 +149,8 @@ rubyforge_project:
|
|
83
149
|
rubygems_version: 1.8.23
|
84
150
|
signing_key:
|
85
151
|
specification_version: 3
|
86
|
-
summary: Gitsu allows you to quickly configure and switch between Git users
|
152
|
+
summary: Gitsu allows you to quickly configure and switch between Git users, for different
|
153
|
+
projects and contexts
|
87
154
|
test_files:
|
88
155
|
- features/add_user.feature
|
89
156
|
- features/change_user_in_different_scopes.feature
|
@@ -103,4 +170,5 @@ test_files:
|
|
103
170
|
- spec/gitsu/switcher_spec.rb
|
104
171
|
- spec/gitsu/user_list_spec.rb
|
105
172
|
- spec/gitsu/user_spec.rb
|
173
|
+
- spec/gitsu/version_spec.rb
|
106
174
|
- spec/spec_helper.rb
|