monolith 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad09131b0f9bc68e0986cacd61f36d1fd9a29bfa
4
+ data.tar.gz: e172518f8110ab6233cbb8d99745a4b237d4d411
5
+ SHA512:
6
+ metadata.gz: 11e96707a34b01ba60979f4b853e0b0114a73567c6d23cca673107d538c58957a27e195aca4123f0456aea6b27bc45f27ece0372c8f3b2bdeb0d45decf8daa84
7
+ data.tar.gz: 6485e4a571247b3c0abf27df3490042c7110f3ecf99dffcd117a686f45f9bc1ba82a37c4626c6af37fcc1f9f693c8627981d40708b4fa2bbfb5fdbb392e47a48
@@ -0,0 +1,2 @@
1
+ monolith.yml
2
+ sandbox
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ monolith (0.0.0)
5
+ cocaine
6
+ colorize
7
+ formatador
8
+ thor
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (4.2.4)
14
+ i18n (~> 0.7)
15
+ json (~> 1.7, >= 1.7.7)
16
+ minitest (~> 5.1)
17
+ thread_safe (~> 0.3, >= 0.3.4)
18
+ tzinfo (~> 1.1)
19
+ climate_control (0.0.3)
20
+ activesupport (>= 3.0)
21
+ cocaine (0.5.7)
22
+ climate_control (>= 0.0.3, < 1.0)
23
+ colorize (0.7.7)
24
+ diff-lcs (1.2.5)
25
+ formatador (0.2.5)
26
+ i18n (0.7.0)
27
+ json (1.8.3)
28
+ minitest (5.8.1)
29
+ rspec (3.3.0)
30
+ rspec-core (~> 3.3.0)
31
+ rspec-expectations (~> 3.3.0)
32
+ rspec-mocks (~> 3.3.0)
33
+ rspec-core (3.3.2)
34
+ rspec-support (~> 3.3.0)
35
+ rspec-expectations (3.3.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.3.0)
38
+ rspec-mocks (3.3.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.3.0)
41
+ rspec-support (3.3.0)
42
+ thor (0.19.1)
43
+ thread_safe (0.3.5)
44
+ tzinfo (1.2.2)
45
+ thread_safe (~> 0.1)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ monolith!
52
+ rspec
53
+
54
+ BUNDLED WITH
55
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Sean Huber - github@shuber.io
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,66 @@
1
+ # [![Sean Huber](https://cloud.githubusercontent.com/assets/2419/6550752/832d9a64-c5ea-11e4-9717-6f9aa6e023b5.png)](https://github.com/shuber) monolith
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/monolith.svg)](http://badge.fury.io/rb/monolith)
4
+
5
+ Generates a single monolithic repository from a list of other git repositories
6
+
7
+ ## Why?
8
+
9
+ * [Google Is 2B Lines of Code, All in One Place](https://news.ycombinator.com/item?id=10227000)
10
+ * [On Monolithic Repositories](https://news.ycombinator.com/item?id=10007654)
11
+ * [Advantages of Monolithic Version Control](https://news.ycombinator.com/item?id=9562923)
12
+
13
+ ## How?
14
+
15
+ * [Merging two, three or more git repositories keeping the log history](http://www.harecoded.com/merging-two-three-or-more-git-repositories-keeping-the-log-history-2366393)
16
+
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ gem install monolith
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Create a `monolith.yml` file in your working directory with a list of repositories
27
+
28
+ ```yaml
29
+ path: /path/to/your/new/monolith
30
+
31
+ repositories:
32
+ admin: git@github.com:some-org/admin.git
33
+ auth: git@github.com:some-org/your-auth-gem.git
34
+ users: git@github.com:some-org/users.git
35
+
36
+ branches: # optional whitelist
37
+ - master
38
+ ```
39
+
40
+ Use the `monolith` command to generate a repository at `/path/to/your/new/monolith`
41
+
42
+ ```bash
43
+ monolith generate
44
+ ```
45
+
46
+ See `monolith help` for a list of other commands
47
+
48
+ ```
49
+ Commands:
50
+ monolith clone # Clone configured repositories
51
+ monolith config # List all configured repositories
52
+ monolith generate # Generate a new monolith from configured repositories
53
+ monolith help [COMMAND] # Describe available commands or one specific command
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ * Fork the project.
59
+ * Make your feature addition or bug fix.
60
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
61
+ * Commit, do not mess with the version or history.
62
+ * Send me a pull request. Bonus points for topic branches.
63
+
64
+ ## License
65
+
66
+ [MIT](https://github.com/shuber/monolith/blob/master/LICENSE) - Copyright © 2015 Sean Huber
@@ -0,0 +1,32 @@
1
+ require "fileutils"
2
+ require "forwardable"
3
+ require "yaml"
4
+
5
+ require "bundler/setup"
6
+ require "cocaine"
7
+ require "colorize"
8
+ require "formatador"
9
+ require "thor"
10
+
11
+ require_relative "monolith/finder"
12
+ require_relative "monolith/logger"
13
+
14
+ require_relative "monolith/branch"
15
+ require_relative "monolith/branch_finder"
16
+ require_relative "monolith/branch_merger"
17
+ require_relative "monolith/branch_name_formatter"
18
+ require_relative "monolith/branch_preparer"
19
+ require_relative "monolith/cli"
20
+ require_relative "monolith/configuration"
21
+ require_relative "monolith/configuration_printer"
22
+ require_relative "monolith/generator"
23
+ require_relative "monolith/git"
24
+ require_relative "monolith/logged_chdir"
25
+ require_relative "monolith/logged_command"
26
+ require_relative "monolith/logged_mkdir"
27
+ require_relative "monolith/repository"
28
+ require_relative "monolith/remote"
29
+ require_relative "monolith/repository_creator"
30
+ require_relative "monolith/repository_finder"
31
+
32
+ require_relative "monolith/application"
@@ -0,0 +1,30 @@
1
+ module Monolith
2
+ class Application < Repository
3
+ attr_reader :config
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ super(config.path)
8
+ end
9
+
10
+ def branch?(name)
11
+ config.branches.empty? || config.branches.include?(name)
12
+ end
13
+
14
+ def checkout_master
15
+ run("checkout master")
16
+ end
17
+
18
+ def create
19
+ RepositoryCreator.new(self).create
20
+ end
21
+
22
+ def merge(repo, branch)
23
+ BranchMerger.new(self, repo, branch).merge
24
+ end
25
+
26
+ def repositories
27
+ RepositoryFinder.new(self)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module Monolith
2
+ class Branch
3
+ attr_reader :name
4
+
5
+ def initialize(repo, name)
6
+ @repo = repo
7
+ @name = name
8
+ end
9
+
10
+ def path
11
+ [@repo.name, name].join("/")
12
+ end
13
+
14
+ def remote
15
+ ["remotes", path].join("/")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ module Monolith
2
+ class BranchFinder
3
+ include Finder
4
+
5
+ def initialize(repo)
6
+ @repo = repo
7
+ end
8
+
9
+ def all
10
+ unique_branches.map do |branch|
11
+ Branch.new(@repo, branch)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def unique_branches
18
+ non_head_branches.uniq
19
+ end
20
+
21
+ def non_head_branches
22
+ formatted_branches.reject do |branch|
23
+ branch =~ /HEAD\s*->/
24
+ end
25
+ end
26
+
27
+ def formatted_branches
28
+ branches.map do |branch|
29
+ BranchNameFormatter.new(branch).name
30
+ end
31
+ end
32
+
33
+ def branches
34
+ @repo.run("branch -a").split("\n")
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ module Monolith
2
+ class BranchMerger
3
+ extend Forwardable
4
+
5
+ def_delegators :@monolith, :run!, :within_working_dir
6
+
7
+ def initialize(monolith, repo, branch)
8
+ @monolith = monolith
9
+ @repo = repo
10
+ @branch = branch
11
+ end
12
+
13
+ def merge
14
+ within_working_dir do
15
+ checkout_branch
16
+ fetch_and_pull_branch
17
+ checkout_previous_branch
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def checkout_branch
24
+ run!("branch #{@branch} || true")
25
+ run!("checkout #{@branch}")
26
+ end
27
+
28
+ def fetch_and_pull_branch
29
+ run!("fetch #{@repo.name} #{@branch}")
30
+ run!("pull #{@repo.name} #{@branch}")
31
+ rescue
32
+ run!("fetch #{@repo.name} master")
33
+ run!("pull #{@repo.name} master")
34
+ ensure
35
+ run!("commit --amend -m '[monolith] Merging #{@repo.name}/master'")
36
+ end
37
+
38
+ def checkout_previous_branch
39
+ run!("checkout -")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ module Monolith
2
+ class BranchNameFormatter
3
+ def initialize(name)
4
+ @name = name
5
+ end
6
+
7
+ def name
8
+ strip_selected_branch_prefix
9
+ strip_whitespace_prefix
10
+ strip_remote_prefix
11
+ @name
12
+ end
13
+
14
+ private
15
+
16
+ def strip_selected_branch_prefix
17
+ strip("*")
18
+ end
19
+
20
+ def strip_whitespace_prefix
21
+ strip(/\s+/)
22
+ end
23
+
24
+ def strip_remote_prefix
25
+ strip("remotes/origin/")
26
+ end
27
+
28
+ def strip(pattern)
29
+ @name.sub!(pattern, "")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,50 @@
1
+ module Monolith
2
+ class BranchPreparer
3
+ extend Forwardable
4
+
5
+ COMMIT = "[monolith] Preparing %s"
6
+
7
+ def_delegators :@repo, :run!, :within_working_dir
8
+
9
+ def initialize(repo, branch)
10
+ @repo = repo
11
+ @branch = branch
12
+ end
13
+
14
+ def prepare
15
+ within_working_dir do
16
+ checkout_branch
17
+ hard_reset_branch
18
+ create_subdir
19
+ move_files_under_subdir
20
+ commit_changes
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def checkout_branch
27
+ run!("branch #{@branch.name} || true")
28
+ run!("checkout #{@branch.name}")
29
+ end
30
+
31
+ def hard_reset_branch
32
+ run!("reset --hard origin/#{@branch.name}")
33
+ end
34
+
35
+ def create_subdir
36
+ LoggedMkdir.new(@repo.name).mkdir
37
+ end
38
+
39
+ def move_files_under_subdir
40
+ files = "ls-tree HEAD | cut -f 2"
41
+ move = "xargs -I file git mv file #{@repo.name}/file"
42
+ run!("#{files} | #{move}")
43
+ end
44
+
45
+ def commit_changes
46
+ message = COMMIT % @branch.path
47
+ run!("commit -m '#{message}'")
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,44 @@
1
+ module Monolith
2
+ class CLI < Thor
3
+ DEFAULT = "monolith.yml"
4
+
5
+ def self.accept_optional_config_file
6
+ method_option :config,
7
+ banner: "/path/to/your/config.yml",
8
+ default: DEFAULT
9
+ end
10
+
11
+ desc "clone", "Clone configured repositories"
12
+ accept_optional_config_file
13
+ def clone
14
+ Generator.new(monolith).clone
15
+ end
16
+
17
+ desc "config", "List all configured repositories"
18
+ accept_optional_config_file
19
+ def config
20
+ ConfigurationPrinter.new(configuration).print
21
+ end
22
+
23
+ desc "generate", "Generate a new monolith from configured repositories"
24
+ accept_optional_config_file
25
+ def generate
26
+ Generator.new(monolith).generate
27
+ end
28
+
29
+ private
30
+
31
+ def monolith
32
+ @monolith ||= Application.new(configuration)
33
+ end
34
+
35
+ def configuration
36
+ @configuration ||= Configuration.new(yaml)
37
+ end
38
+
39
+ def yaml
40
+ file = options.fetch("config")
41
+ File.read(file)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ module Monolith
2
+ class Configuration
3
+ def initialize(yaml)
4
+ @yaml = yaml
5
+ end
6
+
7
+ def branches
8
+ config.fetch("branches", [])
9
+ end
10
+
11
+ def path
12
+ config.fetch("path")
13
+ end
14
+
15
+ def repositories
16
+ config.fetch("repositories")
17
+ end
18
+
19
+ private
20
+
21
+ def config
22
+ @config ||= YAML.load(@yaml)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ module Monolith
2
+ class ConfigurationPrinter
3
+ def initialize(config)
4
+ @config = config
5
+ end
6
+
7
+ def print
8
+ Formatador.display_table([path: @config.path])
9
+ Formatador.display_table(repositories)
10
+ Formatador.display_table(branches) unless branches.empty?
11
+ end
12
+
13
+ private
14
+
15
+ def branches
16
+ @config.branches.map.with_index do |name, index|
17
+ {
18
+ "#" => index + 1,
19
+ "branch name" => name,
20
+ }
21
+ end
22
+ end
23
+
24
+ def repositories
25
+ @config.repositories.map.with_index do |(name, url), index|
26
+ {
27
+ "#" => index + 1,
28
+ "repository name" => name,
29
+ "url" => url,
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module Monolith
2
+ module Finder
3
+ def self.included(mod)
4
+ mod.class_eval do
5
+ extend Forwardable
6
+ include Enumerable
7
+
8
+ def_delegators :all, :each, :size
9
+ end
10
+ end
11
+
12
+ def find_by_name(name)
13
+ detect do |findable|
14
+ findable.name == name
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,107 @@
1
+ module Monolith
2
+ class Generator
3
+ extend Forwardable
4
+ include Logger
5
+
6
+ def_delegators :@monolith, :name, :repositories
7
+
8
+ def initialize(monolith)
9
+ @monolith = monolith
10
+ end
11
+
12
+ def clone
13
+ repositories.each do |repo|
14
+ log("Cloning repository #{repo.name.blue}")
15
+ repo.clone
16
+ end
17
+ end
18
+
19
+ def generate
20
+ clone
21
+ create_monolith
22
+ fetch_all_remotes
23
+ add_remotes_to_monolith
24
+ prepare_branches_for_merge
25
+ merge_branches_into_monolith
26
+ remove_remotes_from_monolith
27
+ checkout_master_on_monolith
28
+ end
29
+
30
+ private
31
+
32
+ def create_monolith
33
+ log("Generating monolith #{name.red}")
34
+ @monolith.create
35
+ end
36
+
37
+ def fetch_all_remotes
38
+ repositories.each do |repo|
39
+ log("Fetching #{repo.name.blue} remotes from #{repo.url.yellow}")
40
+ repo.fetch
41
+ end
42
+ end
43
+
44
+ def add_remotes_to_monolith
45
+ repositories.each do |repo|
46
+ log("Adding remote #{repo.name.blue} to monolith")
47
+ @monolith.remote(repo).add
48
+ end
49
+ end
50
+
51
+ def prepare_branches_for_merge
52
+ repositories.each do |repo|
53
+ repo.branches.each do |branch|
54
+ if @monolith.branch?(branch.name)
55
+ log("Preparing #{repo.name.blue} branch #{branch.name.light_magenta}")
56
+ repo.prepare(branch)
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ def merge_branches_into_monolith
63
+ log("Merging #{branches.size.to_s.yellow} total branches")
64
+
65
+ repositories.each do |repo|
66
+ branches.each do |branch|
67
+ log("Merging #{repo.name.blue} branch #{branch.light_magenta} or master")
68
+ @monolith.merge(repo, branch)
69
+ end
70
+ end
71
+ end
72
+
73
+ def remove_remotes_from_monolith
74
+ repositories.each do |repo|
75
+ log("Removing remote #{repo.name.blue} from monolith")
76
+ @monolith.remote(repo).remove
77
+ end
78
+ end
79
+
80
+ def checkout_master_on_monolith
81
+ log("Checking out monolith master branch")
82
+ @monolith.checkout_master
83
+ end
84
+
85
+ def branches
86
+ filtered_branches.sort
87
+ end
88
+
89
+ def filtered_branches
90
+ unsorted_branches.select do |branch|
91
+ @monolith.branch?(branch)
92
+ end
93
+ end
94
+
95
+ def unsorted_branches
96
+ repositories.each_with_object(Set.new) do |repo, branches|
97
+ repo.branches.each do |branch|
98
+ branches << branch.name
99
+ end
100
+ end
101
+ end
102
+
103
+ def log_prefix
104
+ "==> ".green
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,50 @@
1
+ module Monolith
2
+ class Git
3
+ include Logger
4
+
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def clone(url)
10
+ run("clone #{url} .")
11
+ end
12
+
13
+ def cloned?
14
+ File.exists?(@path)
15
+ end
16
+
17
+ def fetch
18
+ run("fetch --all")
19
+ end
20
+
21
+ def run(cmd)
22
+ within_working_dir do
23
+ run!(cmd)
24
+ end
25
+ end
26
+
27
+ def run!(cmd)
28
+ command(cmd).run
29
+ end
30
+
31
+ def within_working_dir(&block)
32
+ create_working_dir unless cloned?
33
+ cd_working_dir(&block)
34
+ end
35
+
36
+ private
37
+
38
+ def create_working_dir
39
+ LoggedMkdir.new(@path).mkdir
40
+ end
41
+
42
+ def cd_working_dir(&block)
43
+ LoggedChdir.new(@path).chdir(&block)
44
+ end
45
+
46
+ def command(cmd)
47
+ LoggedCommand.new("git", cmd)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,21 @@
1
+ module Monolith
2
+ class LoggedChdir
3
+ include Logger
4
+
5
+ def initialize(dir)
6
+ @dir = dir
7
+ end
8
+
9
+ def chdir(&block)
10
+ return_value = nil
11
+
12
+ Dir.chdir(@dir) do
13
+ log("cd #{@dir}")
14
+ return_value = yield
15
+ log("cd -")
16
+ end
17
+
18
+ return_value
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ module Monolith
2
+ class LoggedCommand < Cocaine::CommandLine
3
+ include Logger
4
+
5
+ private
6
+
7
+ def log(message)
8
+ message.sub!("Command :: ", "")
9
+ super
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module Monolith
2
+ class LoggedMkdir
3
+ include Logger
4
+
5
+ def initialize(dir)
6
+ @dir = dir
7
+ end
8
+
9
+ def mkdir
10
+ log("mkdir -p #{@dir}")
11
+ FileUtils.mkdir_p(@dir)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Monolith
2
+ module Logger
3
+ def log(message)
4
+ puts [log_prefix, message].join
5
+ end
6
+
7
+ private
8
+
9
+ def log_prefix
10
+ " -> ".blue
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Monolith
2
+ class Remote
3
+ extend Forwardable
4
+
5
+ def_delegator :@repo, :run
6
+ def_delegators :@remote, :name, :path
7
+
8
+ def initialize(repo, remote)
9
+ @repo = repo
10
+ @remote = remote
11
+ end
12
+
13
+ def add
14
+ run("remote add #{name} #{path}")
15
+ end
16
+
17
+ def remove
18
+ run("remote remove #{name}")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ module Monolith
2
+ class Repository
3
+ extend Forwardable
4
+
5
+ def_delegators :git, :clone, :cloned?,
6
+ :fetch, :run, :run!,
7
+ :within_working_dir
8
+
9
+ attr_reader :path, :url
10
+
11
+ def initialize(path, url = nil)
12
+ @path = path
13
+ @url = url
14
+ end
15
+
16
+ def branches
17
+ BranchFinder.new(self)
18
+ end
19
+
20
+ def clone
21
+ git.clone(url) unless cloned?
22
+ end
23
+
24
+ def name
25
+ @path.split("/").last
26
+ end
27
+
28
+ def prepare(branch)
29
+ BranchPreparer.new(self, branch).prepare
30
+ end
31
+
32
+ def relative_path
33
+ @path.split("/").tap(&:shift).join("/")
34
+ end
35
+
36
+ def remote(repo)
37
+ Remote.new(self, repo)
38
+ end
39
+
40
+ private
41
+
42
+ def git
43
+ @git ||= Git.new(path)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ module Monolith
2
+ class RepositoryCreator
3
+ extend Forwardable
4
+
5
+ BRANCH = "monolith"
6
+ COMMIT = "[monolith] Initial commit"
7
+
8
+ def_delegators :@repo, :run!, :within_working_dir
9
+
10
+ def initialize(repo)
11
+ @repo = repo
12
+ end
13
+
14
+ def create
15
+ within_working_dir do
16
+ initialize_git_repo
17
+ generate_first_commit
18
+ checkout_monolith_branch
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def initialize_git_repo
25
+ run!("init .")
26
+ end
27
+
28
+ def generate_first_commit
29
+ run!("commit --allow-empty -m '#{COMMIT}'")
30
+ end
31
+
32
+ def checkout_monolith_branch
33
+ run!("checkout -b #{BRANCH}")
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ module Monolith
2
+ class RepositoryFinder
3
+ include Finder
4
+
5
+ def initialize(monolith)
6
+ @monolith = monolith
7
+ end
8
+
9
+ def all
10
+ @monolith.config.repositories.map do |(name, url)|
11
+ path = File.expand_path(name, Dir.pwd)
12
+ Repository.new(path, url)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Monolith
2
+ VERSION = "0.0.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path("../lib/monolith/version", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.author = "Sean Huber"
5
+ s.email = "github@shuber.io"
6
+ s.extra_rdoc_files = %w(LICENSE)
7
+ s.files = `git ls-files`.split("\n")
8
+ s.homepage = "https://github.com/shuber/monolith"
9
+ s.license = "MIT"
10
+ s.name = "monolith"
11
+ s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.md)
12
+ s.require_paths = %w(lib)
13
+ s.required_ruby_version = ">= 2.0.0"
14
+ s.summary = "Monolithic git repository generator"
15
+ s.test_files = `git ls-files -- spec/*`.split("\n")
16
+ s.version = Monolith::VERSION
17
+
18
+ s.add_dependency "cocaine"
19
+ s.add_dependency "colorize"
20
+ s.add_dependency "formatador"
21
+ s.add_dependency "thor"
22
+
23
+ s.add_development_dependency "rspec"
24
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monolith
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Huber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocaine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: formatador
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email: github@shuber.io
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE
94
+ - README.md
95
+ - lib/monolith.rb
96
+ - lib/monolith/application.rb
97
+ - lib/monolith/branch.rb
98
+ - lib/monolith/branch_finder.rb
99
+ - lib/monolith/branch_merger.rb
100
+ - lib/monolith/branch_name_formatter.rb
101
+ - lib/monolith/branch_preparer.rb
102
+ - lib/monolith/cli.rb
103
+ - lib/monolith/configuration.rb
104
+ - lib/monolith/configuration_printer.rb
105
+ - lib/monolith/finder.rb
106
+ - lib/monolith/generator.rb
107
+ - lib/monolith/git.rb
108
+ - lib/monolith/logged_chdir.rb
109
+ - lib/monolith/logged_command.rb
110
+ - lib/monolith/logged_mkdir.rb
111
+ - lib/monolith/logger.rb
112
+ - lib/monolith/remote.rb
113
+ - lib/monolith/repository.rb
114
+ - lib/monolith/repository_creator.rb
115
+ - lib/monolith/repository_finder.rb
116
+ - lib/monolith/version.rb
117
+ - monolith.gemspec
118
+ homepage: https://github.com/shuber/monolith
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options:
124
+ - "--charset=UTF-8"
125
+ - "--inline-source"
126
+ - "--line-numbers"
127
+ - "--main"
128
+ - README.md
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 2.0.0
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.4.5.1
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Monolithic git repository generator
147
+ test_files: []