gitme 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source :rubygems
2
+
3
+ group :default do
4
+ gem "methadone", "~> 0.3.0"
5
+ gem "grit", "~> 2.4.0"
6
+ end
7
+
8
+ group :development do
9
+ gem "jeweler", "~> 1.6.4"
10
+
11
+ gem "rspec", "~> 2.7.0"
12
+ gem "rr", "~> 1.0.0"
13
+ gem "fakefs", "~> 0.4.0"
14
+
15
+ gem "cucumber", "~> 1.1.0"
16
+ gem "aruba", "~> 0.4.0"
17
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Michael Barton
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = gitme
2
+
3
+ == Synopsis
4
+
5
+ The motivation for gitme is make it easy to only keep your git projects on your
6
+ computer as long as you need them. Pull your git project, add your changes,
7
+ push them back, then delete the project once you're done.
8
+
9
+ Problems with this approach is that git repositories have long, difficult to
10
+ remember urls. Git projects may also be additional git remotes and unversioned
11
+ files configuring test tools.
12
+
13
+ Gitme is command line tool to simplify fetching and configuring git projects.
14
+ You should never need to keep a git-backed project on your computer longer than
15
+ you're using it because gitme makes it super-simple to just fetch it again.
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2011 Michael Barton. See LICENSE.txt for further details.
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "gitme"
18
+ gem.homepage = "http://github.com/michaelbarton/gitme"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Command line tool for fetching and configuring git directories}
21
+ gem.email = "mail@michaelbarton.me.uk"
22
+ gem.authors = ["Michael Barton"]
23
+ end
24
+ Jeweler::RubygemsDotOrgTasks.new
25
+
26
+ require 'rspec/core'
27
+ require 'rspec/core/rake_task'
28
+ RSpec::Core::RakeTask.new(:spec) do |spec|
29
+ spec.pattern = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+ require 'cucumber/rake/task'
33
+ Cucumber::Rake::Task.new(:features)
34
+
35
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby -w
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'optparse'
5
+ require 'methadone'
6
+ require 'gitme'
7
+
8
+ include Methadone::Main
9
+
10
+ main do |repository|
11
+ repository_settings = Gitme::CommandLineOptions.new(options).fetch(repository)
12
+ Gitme.new(repository_settings).execute!
13
+ end
14
+
15
+ arg :repository
16
+
17
+ on("-f FILE","--flag","File flag")
18
+
19
+ leak_exceptions true
20
+
21
+ go!
@@ -0,0 +1,16 @@
1
+ Feature: Cloning a repository with gitme
2
+ In order to fetch and configure a repository with gitme
3
+ A user specifies the repository url in a yaml file
4
+ and then calls gitme with the repository name
5
+
6
+ Scenario: Cloning a repository
7
+ Given I write to "gitme.yml" with:
8
+ """
9
+ ---
10
+ test-repo:
11
+ repository: ../../
12
+ """
13
+ And I successfully run `../../bin/gitme -f gitme.yml test-repo`
14
+ When I run `pwd`
15
+ Then the output should contain "test-repo"
16
+ And a directory named ".git" should exist
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
11
+ require 'gitme'
12
+
13
+ require 'rspec/expectations'
14
+ require 'aruba/cucumber'
@@ -0,0 +1,22 @@
1
+ require 'English'
2
+ require 'gitme/command_line_options'
3
+
4
+ class Gitme
5
+ class Error < StandardError; end
6
+
7
+ def initialize(settings)
8
+ @settings = settings
9
+ end
10
+
11
+ def execute!
12
+ clone
13
+ end
14
+
15
+ def clone
16
+ `git clone #{@settings[:repository]} #{@settings[:name]}`
17
+ if $?.exitstatus > 0
18
+ raise(Gitme::Error, "Git failed to clone #{@settings[:repository]}")
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,29 @@
1
+ require 'yaml'
2
+
3
+ class Gitme
4
+ class CommandLineOptions
5
+
6
+ DEFAULT_REPO_FILE = File.expand_path('~/.gitme.yml')
7
+
8
+ attr :repositories
9
+
10
+ def initialize(options)
11
+ @repositories = read_repository_settings(options)
12
+ end
13
+
14
+ def read_repository_settings(options)
15
+ YAML.load(File.read(options[:f] || DEFAULT_REPO_FILE))
16
+ end
17
+
18
+ def fetch(repository)
19
+ unless @repositories[repository]
20
+ raise(Gitme::Error,"Non-existent repository: #{repository}")
21
+ end
22
+ @repositories[repository].inject({:name => repository}) do |hash,pair|
23
+ hash[pair.first.to_sym] = pair.last
24
+ hash
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ gime(1) -- Fetch and configure git projects
2
+ ===========================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `scaffolder` [REPOSITORY]
7
+
8
+ ## DESCRIPTION
9
+
10
+ **Gitme** performs a git clone for the given repository. Initialises the project directory
11
+ according to the directives specified in the *~/.gitmerc* file. Then switches to the git branch containing the last commit.
12
+
13
+ ## CONFIGURATION
14
+
15
+ The *~/.gitmerc* file specifies the repositories that gitme should know and the
16
+ configuration steps require after fetching the repository. An example gitmerc
17
+ may look as follows:
18
+
19
+ ---
20
+ gitme:
21
+ repository: git@github.com:michaelbarton/gitme.git
22
+
23
+ * repository:
24
+ The URL passed to the `git clone` command.
25
+
26
+ ## BUGS
27
+
28
+ **Gitme** is written in Ruby. See the Gemfile in the gitme gem install
29
+ directory for dependencies and version details.
30
+
31
+ ## COPYRIGHT
32
+
33
+ **Gitme** is Copyright (C) 2010 Michael Barton <http://michaelbarton.me.uk>
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitme::CommandLineOptions do
4
+
5
+ describe "#initialize" do
6
+
7
+ before do
8
+ mock(File).read(file) do
9
+ YAML.dump Hash.new
10
+ end
11
+ end
12
+
13
+ describe "with no additional options" do
14
+
15
+ let (:file) do
16
+ File.expand_path '~/.gitme.yml'
17
+ end
18
+
19
+ it "should read the map of repositories from the ~/.gitme.yml" do
20
+ described_class.new({})
21
+ end
22
+
23
+ end
24
+
25
+ describe "with -f file option" do
26
+
27
+ let (:file) do
28
+ 'something'
29
+ end
30
+
31
+ it "should read the map of repositories from the specified file" do
32
+ described_class.new({:f => file})
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ describe "#fetch" do
40
+
41
+ before do
42
+ mock(File).read(anything) do
43
+ YAML.dump repositories
44
+ end
45
+ end
46
+
47
+ subject do
48
+ described_class.new({})
49
+ end
50
+
51
+ let (:repositories) do
52
+ {'repo' => {
53
+ 'repository' => 'path_to_the_repo'
54
+ }}
55
+ end
56
+
57
+ describe "a simple repository" do
58
+
59
+ it "should map the keys to symbols" do
60
+ subject.fetch('repo')[:repository].should == 'path_to_the_repo'
61
+ end
62
+
63
+ it "should map the add the name of the repository as a key" do
64
+ subject.fetch('repo')[:name].should == 'repo'
65
+ end
66
+
67
+ end
68
+
69
+ describe "a non-existent repository" do
70
+
71
+ it "should return the repository settings" do
72
+ lambda{ subject.fetch('non_existent') }.should raise_error(Gitme::Error,
73
+ "Non-existent repository: non_existent")
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitme do
4
+
5
+ let(:name) do
6
+ 'something'
7
+ end
8
+
9
+ let(:repository) do
10
+ File.join(File.dirname(__FILE__),'..','.git')
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "should not generate an error" do
15
+ lambda{ described_class.new({}) }.should_not raise_error
16
+ end
17
+ end
18
+
19
+ describe "#execute!" do
20
+
21
+ subject do
22
+ described_class.new({:repository => repository})
23
+ end
24
+
25
+ it "should call #clone for the specified repository" do
26
+ mock(subject).clone
27
+ subject.execute!
28
+ end
29
+
30
+ end
31
+
32
+ describe "#clone" do
33
+
34
+ describe "a simple repository" do
35
+
36
+ subject do
37
+ described_class.new({:repository => repository, :name => name})
38
+ end
39
+
40
+ it "should clone the specified repository" do
41
+ subject.clone
42
+ File.exists?(name).should be_true
43
+ end
44
+
45
+ after do
46
+ FileUtils.rm_rf(name) if File.exists?(name)
47
+ end
48
+
49
+ end
50
+
51
+ describe "when git fails" do
52
+
53
+ subject do
54
+ described_class.new({:repository => 'non_existent_repo', :name => name})
55
+ end
56
+
57
+ it "should clone the specified repository" do
58
+ lambda{ subject.clone }.should raise_error(Gitme::Error,
59
+ "Git failed to clone non_existent_repo")
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require "tempfile"
4
+ require 'rspec'
5
+ require 'rr'
6
+ require 'gitme'
7
+
8
+ RSpec.configure do |config|
9
+ config.mock_with :rr
10
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Barton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: methadone
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.3.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: grit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.4.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.4.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.4
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: 1.6.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.7.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: 2.7.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rr
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.0.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: fakefs
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.4.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.4.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: cucumber
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.1.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.1.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: aruba
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.4.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.4.0
142
+ description:
143
+ email: mail@michaelbarton.me.uk
144
+ executables:
145
+ - gitme
146
+ extensions: []
147
+ extra_rdoc_files:
148
+ - LICENSE.txt
149
+ - README.rdoc
150
+ files:
151
+ - .document
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.rdoc
155
+ - Rakefile
156
+ - VERSION
157
+ - bin/gitme
158
+ - features/gitme.feature
159
+ - features/step_definitions/gitme_steps.rb
160
+ - features/support/env.rb
161
+ - lib/gitme.rb
162
+ - lib/gitme/command_line_options.rb
163
+ - man/gitme.1.ronn
164
+ - spec/gitme/command_line_options_spec.rb
165
+ - spec/gitme_spec.rb
166
+ - spec/spec_helper.rb
167
+ homepage: http://github.com/michaelbarton/gitme
168
+ licenses:
169
+ - MIT
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ segments:
181
+ - 0
182
+ hash: 571362146618350555
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 1.8.23
192
+ signing_key:
193
+ specification_version: 3
194
+ summary: Command line tool for fetching and configuring git directories
195
+ test_files: []