repository_merger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'repository_merger/commit_history_merger'
4
+ require_relative 'repository_merger/configuration'
5
+ require_relative 'repository_merger/tag_importer'
6
+
7
+ class RepositoryMerger
8
+ attr_reader :configuration
9
+
10
+ def initialize(configuration)
11
+ @configuration = configuration
12
+ end
13
+
14
+ def merge_commit_history_of_branches_named(original_branch_name, commit_message_conversion: nil, progress_title: nil)
15
+ original_branches = configuration.original_repos.map { |repo| repo.branch_for(original_branch_name) }.compact
16
+
17
+ monorepo_head_commit = merge_commit_history_of(
18
+ original_branches,
19
+ commit_message_conversion: commit_message_conversion,
20
+ progress_title: progress_title
21
+ )
22
+
23
+ monorepo_branch_name = original_branches.first.local_name
24
+ configuration.monorepo.create_or_update_branch(monorepo_branch_name, commit_id: monorepo_head_commit.id)
25
+ end
26
+
27
+ def merge_commit_history_of(references, commit_message_conversion: nil, progress_title: nil)
28
+ commit_history_merger = CommitHistoryMerger.new(
29
+ references,
30
+ configuration: configuration,
31
+ commit_message_conversion: commit_message_conversion,
32
+ progress_title: progress_title
33
+ )
34
+
35
+ commit_history_merger.run
36
+ end
37
+
38
+ def import_all_tags(tag_name_conversion:)
39
+ all_tags = configuration.original_repos.flat_map(&:tags)
40
+ import_tags(all_tags, tag_name_conversion: tag_name_conversion)
41
+ end
42
+
43
+ def import_tags(tags, tag_name_conversion:)
44
+ tag_importer = TagImporter.new(tags, configuration: configuration, tag_name_conversion: tag_name_conversion)
45
+ tag_importer.run
46
+ end
47
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/repository_merger/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'repository_merger'
7
+ spec.version = RepositoryMerger::Version.to_s
8
+ spec.authors = ['Yuji Nakayama']
9
+ spec.email = ['nkymyj@gmail.com']
10
+
11
+ spec.summary = 'A tool for merging existing Git repositories into a monorepo with the original commit history'
12
+ spec.homepage = 'https://github.com/yujinakayama/repository_merger'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.7.0'
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
21
+ end
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_runtime_dependency 'ruby-progressbar', '~> 1.11'
28
+ spec.add_runtime_dependency 'rugged', '~> 1.2'
29
+
30
+ # For more information and examples about making a new gem, checkout our
31
+ # guide at: https://bundler.io/guides/creating_gem.html
32
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repository_merger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Nakayama
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-progressbar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ description:
42
+ email:
43
+ - nkymyj@gmail.com
44
+ executables:
45
+ - merge_rspec_repos
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".rspec"
50
+ - ".rubocop.yml"
51
+ - ".rubocop_todo.yml"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - exe/merge_rspec_repos
58
+ - lib/repository_merger.rb
59
+ - lib/repository_merger/branch.rb
60
+ - lib/repository_merger/branch_local_commit_map.rb
61
+ - lib/repository_merger/commit.rb
62
+ - lib/repository_merger/commit_history_merger.rb
63
+ - lib/repository_merger/commit_map.rb
64
+ - lib/repository_merger/configuration.rb
65
+ - lib/repository_merger/github_issue_reference.rb
66
+ - lib/repository_merger/logger.rb
67
+ - lib/repository_merger/mono_repository.rb
68
+ - lib/repository_merger/reference.rb
69
+ - lib/repository_merger/repository.rb
70
+ - lib/repository_merger/repository_commit_map.rb
71
+ - lib/repository_merger/tag.rb
72
+ - lib/repository_merger/tag_importer.rb
73
+ - lib/repository_merger/version.rb
74
+ - repository_merger.gemspec
75
+ homepage: https://github.com/yujinakayama/repository_merger
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.7.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.1.6
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A tool for merging existing Git repositories into a monorepo with the original
98
+ commit history
99
+ test_files: []