conjoiner 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +15 -0
- data/README.md +13 -0
- data/conjoiner.gemspec +15 -11
- data/lib/conjoiner/cli.rb +68 -18
- data/lib/conjoiner/configuration.rb +40 -0
- data/lib/conjoiner/version.rb +1 -1
- data/lib/conjoiner.rb +1 -0
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81ccd5489780454659c657ca55ad9f48333f4834d87688cff68bd9b90f9aba6b
|
4
|
+
data.tar.gz: 17ac85e833af9fa8af956ed715fe0ea64625ec6391191fd623bb221cf1afbc73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519fa71b2216bce70c7abb0ea34f2276cd8cf08fddbabd69f0922a6baea8fb9df5189cca7df9c4b0270ba4fe1adecfd588cf49956cb746cb23b85843104b6542
|
7
|
+
data.tar.gz: e0368e4402685bb78dc5695d8142d1d2df64b8699bf2fc181ca0c31dc63c8cb311ec461192c8a4641c297ea848480a0e7d351d9d2240f9f340306c8ae0dbcafb
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,3 +5,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.2.0] - 2012-12-24
|
10
|
+
### Added
|
11
|
+
- Command to clone an arbitrary repository into the `~/joined` directory
|
12
|
+
structure
|
13
|
+
- Command to list all the remote origins of the joined repositories
|
14
|
+
- Add configuration file for specifying the default aspect
|
15
|
+
|
16
|
+
## [0.1.0] - 2012-11-12
|
17
|
+
### Added
|
18
|
+
- Initializing dated aspect directories
|
19
|
+
- Manual synchronization command
|
20
|
+
- Show command to display git status of aspect directories
|
21
|
+
- Synchronization mode to watch aspect repositories, committing and pushing
|
22
|
+
changes
|
data/README.md
CHANGED
@@ -41,6 +41,14 @@ And show the status of the repositories with:
|
|
41
41
|
conjoiner show
|
42
42
|
```
|
43
43
|
|
44
|
+
You can also clone arbitrary repositories into the `joined` directory with:
|
45
|
+
```
|
46
|
+
conjoiner clone git@gitlab.com:acant/conjoiner.git
|
47
|
+
```
|
48
|
+
|
49
|
+
This repository would be cloned to `$HOME/joined/gitlab.com/acant/conjoiner`.
|
50
|
+
|
51
|
+
|
44
52
|
### Enable the synchronization deaemon on with systemd on Linux
|
45
53
|
|
46
54
|
You can enable the automatic synchronization with the following script:
|
@@ -79,6 +87,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
79
87
|
|
80
88
|
Bug reports and merge requests are welcome on Gitlab at https://gitlab.com/acant/conjoiner.
|
81
89
|
|
90
|
+
## Similar projects
|
91
|
+
|
92
|
+
* https://myrepos.branchable.com/
|
93
|
+
* https://github.com/nesquena/gitdocs
|
94
|
+
|
82
95
|
## License
|
83
96
|
|
84
97
|
Released under the [AGPLv3 license](https://www.gnu.org/licenses/agpl-3.0.en.html).
|
data/conjoiner.gemspec
CHANGED
@@ -11,9 +11,10 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = 'Manager for cloned git reporitories, automatically sync some of those repositories.'
|
12
12
|
spec.homepage = 'https://gitlab.com/acant/conjoiner'
|
13
13
|
spec.metadata = {
|
14
|
-
'homepage_uri'
|
15
|
-
'source_code_uri'
|
16
|
-
'changelog_uri'
|
14
|
+
'homepage_uri' => spec.homepage,
|
15
|
+
'source_code_uri' => spec.homepage,
|
16
|
+
'changelog_uri' => "#{spec.homepage}/CHANGELOG.md",
|
17
|
+
'rubygems_mfa_required' => 'true'
|
17
18
|
}
|
18
19
|
spec.license = 'AGPL-3.0-or-later'
|
19
20
|
spec.files =
|
@@ -28,15 +29,18 @@ Gem::Specification.new do |spec|
|
|
28
29
|
|
29
30
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
30
31
|
|
31
|
-
spec.add_dependency 'git',
|
32
|
-
spec.add_dependency '
|
33
|
-
spec.add_dependency '
|
34
|
-
spec.add_dependency '
|
32
|
+
spec.add_dependency 'git', '~> 1.9'
|
33
|
+
spec.add_dependency 'git_clone_url', '~> 2.0'
|
34
|
+
spec.add_dependency 'listen', '~> 3.6'
|
35
|
+
spec.add_dependency 'table_print', '~> 1.5'
|
36
|
+
spec.add_dependency 'thor', '~> 1.0'
|
35
37
|
|
36
|
-
spec.add_development_dependency 'aruba',
|
37
|
-
spec.add_development_dependency 'cucumber',
|
38
|
-
spec.add_development_dependency '
|
39
|
-
spec.add_development_dependency '
|
38
|
+
spec.add_development_dependency 'aruba', '~> 1.0'
|
39
|
+
spec.add_development_dependency 'cucumber', '~> 5.3'
|
40
|
+
spec.add_development_dependency 'fakefs', '~> 1.4.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
42
|
+
spec.add_development_dependency 'rspec-tabular', '~> 0.2'
|
43
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
40
44
|
|
41
45
|
spec.add_development_dependency 'bundler-audit'
|
42
46
|
spec.add_development_dependency 'rubocop'
|
data/lib/conjoiner/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'thor'
|
4
4
|
require 'git'
|
5
|
+
require 'git_clone_url'
|
5
6
|
require 'pathname'
|
6
7
|
require 'table_print'
|
7
8
|
require 'ostruct'
|
@@ -18,7 +19,7 @@ module Conjoiner
|
|
18
19
|
desc 'init_aspect [ASPECT] [YEAR]', 'initialize aspect for a year'
|
19
20
|
options year: :integer
|
20
21
|
def init_aspect(aspect = nil, year = nil)
|
21
|
-
aspect ||=
|
22
|
+
aspect ||= configuration.default_aspect
|
22
23
|
year ||= Time.now.year
|
23
24
|
|
24
25
|
puts "init aspect #{aspect} #{year}"
|
@@ -34,20 +35,10 @@ module Conjoiner
|
|
34
35
|
year.to_s
|
35
36
|
)
|
36
37
|
|
37
|
-
|
38
|
-
if aspect == 'prime'
|
39
|
-
%w[gpx log misc]
|
40
|
-
else
|
41
|
-
%w[log]
|
42
|
-
end
|
43
|
-
|
44
|
-
repository_names.each do |name|
|
38
|
+
configuration.dated_repository_names.each do |name|
|
45
39
|
repo = "gitolite@git.andrewcant.ca:andrew/aspects/#{aspect}/dated/#{year}/#{name}"
|
46
40
|
dir = dated_root.join(name)
|
47
41
|
|
48
|
-
puts repo
|
49
|
-
puts dir
|
50
|
-
|
51
42
|
git =
|
52
43
|
if dir.exist?
|
53
44
|
begin
|
@@ -96,9 +87,34 @@ module Conjoiner
|
|
96
87
|
end
|
97
88
|
end
|
98
89
|
|
90
|
+
desc 'clone [URL]', 'clone the repository into the joined directory'
|
91
|
+
def clone(url)
|
92
|
+
home = Pathname.new(Dir.home)
|
93
|
+
joined_dir = home.join('joined')
|
94
|
+
|
95
|
+
# Create repository pathname from the URL.
|
96
|
+
git_clone_url = GitCloneUrl.parse(url)
|
97
|
+
path_parts = git_clone_url.path.sub(%r{^/}, '').sub(/\.git$/, '').split('/')
|
98
|
+
repository_pathname =
|
99
|
+
joined_dir
|
100
|
+
.join(git_clone_url.host)
|
101
|
+
.join(*path_parts)
|
102
|
+
|
103
|
+
# Clone is repository if it is not already present.
|
104
|
+
if repository_pathname.exist?
|
105
|
+
puts "Already cloned at #{repository_pathname}"
|
106
|
+
else
|
107
|
+
puts "Clone #{url} to #{repository_pathname}"
|
108
|
+
repository_pathname.mkpath
|
109
|
+
Git.clone(url, repository_pathname)
|
110
|
+
end
|
111
|
+
rescue URI::Error
|
112
|
+
puts "Invalid URL <#{url}>"
|
113
|
+
end
|
114
|
+
|
99
115
|
desc 'sync', 'run the repository synchronization once'
|
100
116
|
def sync(aspect = nil, year = nil)
|
101
|
-
aspect ||=
|
117
|
+
aspect ||= configuration.default_aspect
|
102
118
|
year ||= Time.now.year
|
103
119
|
|
104
120
|
home = Pathname.new(Dir.home)
|
@@ -150,9 +166,8 @@ module Conjoiner
|
|
150
166
|
'aspects'
|
151
167
|
)
|
152
168
|
|
153
|
-
current_aspects = %w[prime sugar]
|
154
169
|
listen_pathnames =
|
155
|
-
|
170
|
+
configuration.aspects.map do |aspect|
|
156
171
|
aspect_dir = aspects_root.join(aspect)
|
157
172
|
[
|
158
173
|
aspect_dir.join('dated', year.to_s),
|
@@ -170,7 +185,7 @@ module Conjoiner
|
|
170
185
|
listen_pathnames.map { |x| x.glob('**/.git').map(&:dirname) }.flatten
|
171
186
|
|
172
187
|
puts 'For these aspects:'
|
173
|
-
|
188
|
+
configuration.aspects.each { |x| puts " * #{x}" }
|
174
189
|
puts 'Watch the following repositories:'
|
175
190
|
listen_repository_pathnames.each { |x| puts " * #{x}" }
|
176
191
|
|
@@ -225,7 +240,7 @@ module Conjoiner
|
|
225
240
|
|
226
241
|
desc 'show [PATH]', 'show the status of aspects and other repositories'
|
227
242
|
def show(aspect = nil, year = nil)
|
228
|
-
aspect ||=
|
243
|
+
aspect ||= configuration.default_aspect
|
229
244
|
year ||= Time.now.year
|
230
245
|
|
231
246
|
home = Pathname.new(Dir.home)
|
@@ -250,7 +265,7 @@ module Conjoiner
|
|
250
265
|
output =
|
251
266
|
gits.map do |git|
|
252
267
|
additions = git.status.added.count + git.status.changed.count
|
253
|
-
OpenStruct.new(
|
268
|
+
OpenStruct.new( # rubocop:disable Style/OpenStructUse
|
254
269
|
path: Pathname.new(git.dir.to_s).relative_path_from(joined_dir).to_s,
|
255
270
|
status: "+#{additions} -#{git.status.deleted.count} *#{git.status.untracked.count}"
|
256
271
|
)
|
@@ -259,6 +274,41 @@ module Conjoiner
|
|
259
274
|
tp.set(:max_width, 256)
|
260
275
|
tp(output, :path, :status)
|
261
276
|
end
|
277
|
+
|
278
|
+
desc 'ls', 'show all the joined repositories'
|
279
|
+
option :origin, type: :boolean, aliases: :o
|
280
|
+
option :noorigin, type: :boolean, aliases: :no
|
281
|
+
def ls
|
282
|
+
home = Pathname.new(Dir.home)
|
283
|
+
joined_dir = home.join('joined')
|
284
|
+
result = []
|
285
|
+
joined_dir.find do |pathname|
|
286
|
+
next unless pathname.directory? && pathname.join('.git').directory?
|
287
|
+
|
288
|
+
if options[:origin]
|
289
|
+
origin_url = Git.open(pathname).remote('origin').url
|
290
|
+
result.push(origin_url) if origin_url
|
291
|
+
elsif options[:noorigin]
|
292
|
+
origin_url = Git.open(pathname).remote('origin').url
|
293
|
+
result.push(pathname) unless origin_url
|
294
|
+
else
|
295
|
+
result.push(pathname)
|
296
|
+
end
|
297
|
+
|
298
|
+
Find.prune
|
299
|
+
end
|
300
|
+
|
301
|
+
result.sort.each { |x| puts x }
|
302
|
+
end
|
303
|
+
|
304
|
+
############################################################################
|
305
|
+
|
306
|
+
private
|
307
|
+
|
308
|
+
# @return [Conjoiner::Configuration]
|
309
|
+
def configuration
|
310
|
+
@configuration ||= Configuration.new
|
311
|
+
end
|
262
312
|
end
|
263
313
|
end
|
264
314
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Conjoiner
|
4
|
+
# @private
|
5
|
+
# Frontend for determining the configuration of conjoiner. Either using
|
6
|
+
# defaults specified in this file, or overridden by configuration located in:
|
7
|
+
# ~/.config/conjoiner/
|
8
|
+
class Configuration
|
9
|
+
# @return [Array<String>]
|
10
|
+
def aspects
|
11
|
+
%w[prime sugar]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
def default_aspect
|
16
|
+
return @default_aspect if @default_aspect
|
17
|
+
|
18
|
+
default_aspect_pathname =
|
19
|
+
Pathname.new(Dir.home).join('.config', 'conjoiner', 'default_aspect')
|
20
|
+
|
21
|
+
@default_aspect =
|
22
|
+
if default_aspect_pathname.readable?
|
23
|
+
default_aspect_pathname.read.strip
|
24
|
+
else
|
25
|
+
'prime'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param aspect [String]
|
30
|
+
#
|
31
|
+
# @return [Array<String>]
|
32
|
+
def dated_repository_names(aspect)
|
33
|
+
if aspect == 'prime'
|
34
|
+
%w[gpx log misc]
|
35
|
+
else
|
36
|
+
%w[log]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/conjoiner/version.rb
CHANGED
data/lib/conjoiner.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjoiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Sullivan Cant
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: git_clone_url
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: listen
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '5.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fakefs
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.4.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.4.0
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: rspec
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +136,20 @@ dependencies:
|
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '3.10'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-tabular
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.2'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.2'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: simplecov
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -233,6 +275,7 @@ files:
|
|
233
275
|
- exe/conjoiner
|
234
276
|
- lib/conjoiner.rb
|
235
277
|
- lib/conjoiner/cli.rb
|
278
|
+
- lib/conjoiner/configuration.rb
|
236
279
|
- lib/conjoiner/version.rb
|
237
280
|
homepage: https://gitlab.com/acant/conjoiner
|
238
281
|
licenses:
|
@@ -241,6 +284,7 @@ metadata:
|
|
241
284
|
homepage_uri: https://gitlab.com/acant/conjoiner
|
242
285
|
source_code_uri: https://gitlab.com/acant/conjoiner
|
243
286
|
changelog_uri: https://gitlab.com/acant/conjoiner/CHANGELOG.md
|
287
|
+
rubygems_mfa_required: 'true'
|
244
288
|
post_install_message:
|
245
289
|
rdoc_options: []
|
246
290
|
require_paths:
|