git-superproject 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 77488a891a2ea164436a18c086dbcf6a6cf513a9
4
+ data.tar.gz: c3f27a89cae98a4a10321dd1ef1c2502ae77fe21
5
+ SHA512:
6
+ metadata.gz: 7e9abceba6edf0114c3617c0a59d0bc846de28ed246dcda94fbd3d6ff7c2a31d290e20e1841415dc65a244d784cb45661a832957a6a7df30d0ecd55c2c30f164
7
+ data.tar.gz: 110cd34163237523a33118436e60db3b5543fee03d9c292a1d6bff4b1179470630d7718079ca564ac2d689a878af50708b449fe25f768d88ab63874df70401e8
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ Layout/EmptyLinesAroundClassBody:
2
+ Enabled: false
3
+ Layout/EmptyLinesAroundModuleBody:
4
+ Enabled: false
5
+
6
+ Lint/HandleExceptions:
7
+ Enabled: false
8
+
9
+ Metrics/AbcSize:
10
+ Enabled: false
11
+ Metrics/BlockNesting:
12
+ Enabled: false
13
+ Metrics/LineLength:
14
+ Enabled: false
15
+ Metrics/MethodLength:
16
+ Enabled: false
17
+ Metrics/ModuleLength:
18
+ Enabled: false
19
+
20
+ Style/BlockDelimiters:
21
+ Enabled: false
22
+ Style/Documentation:
23
+ Enabled: false
24
+ Style/FrozenStringLiteralComment:
25
+ Enabled: false
26
+ Style/Lambda:
27
+ Enabled: false
28
+ Style/NestedTernaryOperator:
29
+ Enabled: false
30
+ Style/RedundantBegin:
31
+ Enabled: false
32
+ Style/SingleLineMethods:
33
+ Enabled: false
34
+ Style/TrailingCommaInArguments:
35
+ Enabled: false
36
+ Style/TrailingCommaInArrayLiteral:
37
+ Enabled: false
38
+ Style/TrailingCommaInHashLiteral:
39
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.8
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in git-superproject.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Git::Superproject
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/git/superproject`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'git-superproject'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install git-superproject
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/git-superproject.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # rubocop:disable Style/SymbolArray
2
+ # rubocop:disable Style/HashSyntax
3
+
4
+ require 'bundler/gem_tasks'
5
+
6
+ task :validate_gemspec do
7
+ Bundler.load_gemspec('git-superproject.gemspec').validate
8
+ end
9
+
10
+ task :version => :validate_gemspec do
11
+ puts Git::Superproject::VERSION
12
+ end
13
+
14
+ require 'rubocop/rake_task'
15
+
16
+ RuboCop::RakeTask.new(:rubocop)
17
+
18
+ require 'rake/testtask'
19
+
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'test'
22
+ t.libs << 'lib'
23
+ t.test_files = FileList['test/**/*_test.rb']
24
+ end
25
+
26
+ task :default => [:rubocop, :test]
27
+
28
+ task :documentation
29
+
30
+ Rake::Task['build'].enhance([:default, :documentation])
31
+
32
+ # rubocop:enable Style/HashSyntax
33
+ # rubocop:enable Style/SymbolArray
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'git/superproject'
5
+
6
+ require 'pry'
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'git/superproject'
6
+
7
+ if (command = ARGV.shift)&.start_with? '++'
8
+ name = command[2..-1]
9
+ command = nil
10
+ end
11
+
12
+ # TODO: acquire flock on "~/.git/multi/superprojects.config"
13
+
14
+ case (command ||= ARGV.shift)
15
+ when /\A--/
16
+ case command
17
+ when '--version' then Git::Superproject::Commands.version
18
+ when '--help' then Git::Superproject::Commands.help
19
+ else
20
+ config = Git::Superproject::Config.from(Git::SUPERPROJECTS_CONFIG)
21
+ case command
22
+ when '--config' then puts config.to_json
23
+ else
24
+ unless name
25
+ warn 'No superproject specified... aborting!'
26
+ exit(-1)
27
+ end
28
+ case command
29
+ when '--list' then puts config.list(name).to_json
30
+ when '--add' then puts config.add(name, ARGV).to_json
31
+ when '--remove' then puts config.remove(name, ARGV).to_json
32
+ else
33
+ abort \
34
+ "Unknown 'git superproject' command: #{command}\n\n" \
35
+ '(use --help/-h to list all available commands)'
36
+ end
37
+ config.write_to(Git::SUPERPROJECTS_CONFIG)
38
+ end
39
+ end
40
+ when nil, '', '-h'
41
+ Git::Superproject::Commands.help
42
+ end
43
+
44
+ # TODO: release flock on "~/.git/multi/superprojects.config"
45
+
46
+ # That's all Folks!
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'git/superproject/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = Git::Superproject::NAME
7
+ spec.version = Git::Superproject::VERSION
8
+ spec.authors = ['Peter Vandenberk']
9
+ spec.email = ['pvandenberk@mac.com']
10
+
11
+ spec.summary = 'Utility to manipulate `superprojects.config`'
12
+ spec.description = 'CLI utilities for managing superproject configs'
13
+ spec.homepage = 'https://github.com/pvdb/git-superproject'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`
18
+ .split("\x0")
19
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'pry'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rubocop'
29
+ end
@@ -0,0 +1,6 @@
1
+ module Git
2
+ module Superproject
3
+ NAME = 'git-superproject'.freeze
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
@@ -0,0 +1,96 @@
1
+ require 'git/superproject/version'
2
+
3
+ require 'json'
4
+ require 'English'
5
+ require 'pathname'
6
+ require 'fileutils'
7
+
8
+ module Git
9
+
10
+ HOME = Pathname.new(Dir.home)
11
+ GIT_MULTI_DIR = HOME.join('.git', 'multi')
12
+ SUPERPROJECTS_CONFIG = GIT_MULTI_DIR.join('superprojects.config')
13
+
14
+ module Superproject
15
+ class Error < StandardError; end
16
+
17
+ class Config
18
+
19
+ def self.from(file)
20
+ new(
21
+ `git config --file #{file} --list`
22
+ .split($RS)
23
+ .map(&:strip)
24
+ )
25
+ end
26
+
27
+ def initialize(key_value_pairs)
28
+ @superprojects = Hash.new do |superprojects, name|
29
+ superprojects[name] = []
30
+ end
31
+
32
+ key_value_pairs.each do |key_value|
33
+ key, value = key_value.split('=')
34
+
35
+ key =~ /\Asuperproject\.(?<name>.*)\.repo\z/
36
+ raise "Invalid superproject key: #{key}" unless $LAST_MATCH_INFO
37
+
38
+ name = $LAST_MATCH_INFO[:name]
39
+
40
+ value =~ %r{\A[-\w]+/[-\w]+\z}
41
+ raise "Invalid repo name: #{value}" unless $LAST_MATCH_INFO
42
+
43
+ @superprojects[name] << value
44
+ end
45
+ end
46
+
47
+ def list(name)
48
+ @superprojects[name]
49
+ end
50
+
51
+ def add(name, repos)
52
+ repos.each do |repo|
53
+ @superprojects[name] << repo
54
+ end
55
+ @superprojects[name]
56
+ end
57
+
58
+ def remove(name, repos)
59
+ repos.each do |repo|
60
+ @superprojects[name].delete(repo)
61
+ end
62
+ @superprojects[name]
63
+ end
64
+
65
+ def write_to(file)
66
+ # create backup of original file
67
+ FileUtils.mv(file, "#{file}~") if File.exist? file
68
+
69
+ @superprojects.each do |name, repos|
70
+ name = "superproject.#{name}.repo"
71
+ repos.each do |repo|
72
+ `git config --file #{file} --add #{name} #{repo}`
73
+ end
74
+ end
75
+
76
+ # copy across all the comments from the original file
77
+ `egrep '^# ' "#{file}~" >> "#{file}"`
78
+ end
79
+
80
+ def to_json
81
+ @superprojects.to_json
82
+ end
83
+
84
+ end
85
+
86
+ module Commands
87
+ def self.version
88
+ puts Git::Superproject::VERSION
89
+ end
90
+
91
+ def self.help
92
+ puts 'git superproject ++bolt --list'
93
+ end
94
+ end
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-superproject
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter Vandenberk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: CLI utilities for managing superproject configs
70
+ email:
71
+ - pvandenberk@mac.com
72
+ executables:
73
+ - git-superproject
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - exe/git-superproject
87
+ - git-superproject.gemspec
88
+ - lib/git/superproject.rb
89
+ - lib/git/superproject/version.rb
90
+ homepage: https://github.com/pvdb/git-superproject
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.5.2.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Utility to manipulate `superprojects.config`
114
+ test_files: []