giternal-digarc 0.1.1Digarc

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.
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
+
3
+ module Giternal
4
+ describe YamlConfig do
5
+ it "should create repositories from the config" do
6
+ config = YamlConfig.new('base_dir',
7
+ "rspec:\n repo: git://rspec\n path: vendor/plugins\n" +
8
+ "foo:\n repo: git://at/foo\n path: path/to/foo\n")
9
+ Repository.should_receive(:new).with('base_dir', "rspec", "git://rspec", "vendor/plugins").and_return :a_repo
10
+ Repository.should_receive(:new).with('base_dir', "foo", "git://at/foo", "path/to/foo").and_return :a_repo
11
+ config.each_repo {|r| r.should == :a_repo}
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,16 @@
1
+ begin
2
+ require 'rspec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'rspec'
6
+ end
7
+
8
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
9
+ require 'giternal'
10
+ require 'fileutils'
11
+ require 'giternal_helper'
12
+
13
+ RSpec.configure do |config|
14
+ config.before { GiternalHelper.clean! }
15
+ config.after { GiternalHelper.clean! }
16
+ end
@@ -0,0 +1,157 @@
1
+ require 'fileutils'
2
+ module Repomanipulator
3
+ def repo_path(path)
4
+ File.expand_path File.join(File.dirname(__FILE__), "test_repos", path)
5
+ end
6
+
7
+ def create_repo(name)
8
+ path = repo_path(name)
9
+ FileUtils.mkdir_p(path)
10
+ Dir.chdir(path) do
11
+ `git init`
12
+ `echo first_file > first_file`
13
+ end
14
+ commit_all path, "created repo"
15
+ end
16
+
17
+ def commit_all(path, message)
18
+ Dir.chdir(path) do
19
+ `git add .`
20
+ puts `git commit -m "#{message}"`
21
+ end
22
+ end
23
+
24
+ def clone_repo(from, to, options=nil)
25
+ Dir.chdir(repo_path("")) { `git clone #{options} #{from} #{to}` }
26
+ end
27
+
28
+ def add_content_to(file, content)
29
+ path = repo_path file
30
+ FileUtils.touch path
31
+ File.open(path, 'w') {|f| f << content }
32
+ `cd #{File.dirname(path)} && git checkout master`
33
+ commit_all File.dirname(repo_path(file)), "added content to #{file}"
34
+ end
35
+
36
+ def push(repo)
37
+ Dir.chdir(repo_path(repo)) { `git push origin master` }
38
+ end
39
+
40
+ def pull(repo)
41
+ Dir.chdir(repo_path(repo)) { puts `git pull` }
42
+ end
43
+
44
+ def verify_repo_has_files(repo, *files)
45
+ Dir.chdir(repo_path(repo)) do
46
+ missing_files = files.select {|f| !File.exist?(f) }
47
+ raise "Expected files: [#{missing_files.join(', ')}] to exist in #{repo} but are missing" unless missing_files.empty?
48
+ end
49
+ end
50
+ end
51
+ include Repomanipulator
52
+
53
+ module GitSubmodules
54
+ def add_external(base, external)
55
+ external_path = repo_path(external)
56
+ Dir.chdir(repo_path(base)) { puts `git submodule add #{external_path} #{external}` }
57
+ commit_all repo_path(base), "committed external #{external}"
58
+ end
59
+
60
+ def update_externals(repo)
61
+ Dir.chdir(repo_path(repo)) do
62
+ puts `git submodule init`
63
+ puts `git submodule update`
64
+ end
65
+ commit_all repo_path(repo), "updated externals"
66
+ end
67
+ end
68
+
69
+ module Giternal
70
+ def add_external(base, external)
71
+ external_path = repo_path external
72
+ Dir.chdir(repo_path(base)) do
73
+ FileUtils.touch ".giternal.yml"
74
+ File.open(".giternal.yml", 'w') do |f|
75
+ f << external << ":\n"
76
+ f << " repo: #{external_path}\n"
77
+ f << " path: ."
78
+ end
79
+ `echo #{external} >> .gitignore`
80
+ end
81
+ commit_all repo_path(base), "added #{external}"
82
+ end
83
+
84
+ def update_externals(base)
85
+ Dir.chdir(repo_path(base)) { puts `giternal update` }
86
+ end
87
+ end
88
+
89
+ module Braid
90
+ def add_external(base, external)
91
+ external_path = repo_path external
92
+ Dir.chdir(repo_path(base)) { puts `braid add --type git #{external_path} #{external}` }
93
+ end
94
+
95
+ def update_externals(base)
96
+ Dir.chdir(repo_path(base)) { puts `braid update` }
97
+ end
98
+ end
99
+
100
+
101
+ drivers = {"submodules" => GitSubmodules, "giternal" => Giternal, "braid" => Braid}
102
+ unless drivers.keys.include?(ARGV.first)
103
+ puts "Run with: ruby test_tracking.rb #{drivers.keys.join('|')}"
104
+ exit
105
+ end
106
+ include drivers[ARGV.first]
107
+
108
+ FileUtils.rm_rf repo_path("")
109
+
110
+ def ALERT(message)
111
+ puts
112
+ puts "*** " + message
113
+ end
114
+
115
+ ALERT "the project has will_paginate as an external"
116
+ create_repo "will_paginate-full"
117
+ clone_repo "will_paginate-full", "will_paginate", "--bare"
118
+
119
+ create_repo "base-full"
120
+ add_external "base-full", "will_paginate"
121
+ clone_repo "base-full", "base", "--bare"
122
+
123
+ ALERT "Joe and Sarah clone copies of the project"
124
+ clone_repo "base", "joe"
125
+ update_externals "joe"
126
+
127
+ clone_repo "base", "sarah"
128
+ update_externals "sarah"
129
+
130
+ ALERT "Joe adds README to will_paginate and commits"
131
+ add_content_to "joe/will_paginate/README", "some content"
132
+
133
+ ALERT "Joe commits a change to the base project"
134
+ add_content_to "joe/foo", "in the base project"
135
+
136
+ ALERT "Joe pushes his code"
137
+ push "joe"
138
+ push "joe/will_paginate"
139
+
140
+ ALERT "Sarah adds LICENSE to her repo and commits"
141
+ add_content_to "sarah/will_paginate/LICENSE", "gnu baby"
142
+
143
+ ALERT "Sarah commits a change to the base project"
144
+ add_content_to "sarah/bar", "in the base project"
145
+
146
+ ALERT "Sarah pulls from base project and updates externals"
147
+ pull "sarah"
148
+ update_externals "sarah"
149
+ push "sarah/will_paginate"
150
+
151
+ ALERT "Does the cloned project have all the files we expect?"
152
+ verify_repo_has_files("sarah", "foo", "bar", "will_paginate/README", "will_paginate/LICENSE")
153
+
154
+ ALERT "Does the upstream external have all the files we expect?"
155
+ clone_repo "will_paginate", "will_paginate_clone"
156
+ verify_repo_has_files "will_paginate_clone", "README", "LICENSE"
157
+ puts "woooo! Collaboration ftw"
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: giternal-digarc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1Digarc
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Pat Maddox
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2009-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
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: cucumber
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
+ description: Giternal provides dead-simple management of external git dependencies.
47
+ It only stores a small bit of metadata, letting you actively develop in any of the
48
+ repos. Come deploy time, you can easily freeze freeze all the dependencies to particular
49
+ versions
50
+ email: pat.maddox@gmail.com
51
+ executables:
52
+ - giternal
53
+ extensions: []
54
+ extra_rdoc_files:
55
+ - LICENSE
56
+ - README.rdoc
57
+ files:
58
+ - .emacs-project
59
+ - .gitignore
60
+ - LICENSE
61
+ - README.rdoc
62
+ - Rakefile
63
+ - VERSION.yml
64
+ - bin/giternal
65
+ - features/checking_out_externals.feature
66
+ - features/freeze_externals.feature
67
+ - features/steps/repository_steps.rb
68
+ - features/unfreeze_externals.feature
69
+ - giternal.gemspec
70
+ - giternal_helper.rb
71
+ - lib/giternal.rb
72
+ - lib/giternal/app.rb
73
+ - lib/giternal/repository.rb
74
+ - lib/giternal/version.rb
75
+ - lib/giternal/yaml_config.rb
76
+ - spec/giternal/app_spec.rb
77
+ - spec/giternal/repository_spec.rb
78
+ - spec/giternal/yaml_config_spec.rb
79
+ - spec/spec.opts
80
+ - spec/spec_helper.rb
81
+ - test_trackers.rb
82
+ homepage: http://github.com/pat-maddox/giternal
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options:
86
+ - --charset=UTF-8
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.24
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Non-sucky git externals
107
+ test_files:
108
+ - spec/giternal/app_spec.rb
109
+ - spec/giternal/repository_spec.rb
110
+ - spec/giternal/yaml_config_spec.rb
111
+ - spec/spec_helper.rb