dotter_dotfiles 0.2.0 → 0.3.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 +4 -4
- data/.codeclimate.yml +10 -0
- data/.rubocop.yml +1171 -0
- data/ChangeLog.md +5 -0
- data/README.md +30 -5
- data/bin/dotter +1 -1
- data/lib/dotter/cli.rb +195 -180
- data/lib/dotter/configuration.rb +52 -35
- data/lib/dotter/foreigngitrepo.rb +29 -0
- data/lib/dotter/gitrepo.rb +49 -40
- data/lib/dotter/package.rb +76 -55
- data/lib/dotter/publicgitrepo.rb +42 -37
- data/lib/dotter/utilities.rb +39 -33
- data/lib/dotter/version.rb +1 -1
- metadata +5 -2
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'dotter/utilities'
|
3
|
+
module Dotter
|
4
|
+
class ForeignGitRepo < GitRepo
|
5
|
+
def initialize(package, init = false, source_repository = '')
|
6
|
+
@package = package
|
7
|
+
@project_path = package_path(package)
|
8
|
+
@origin = source_repository
|
9
|
+
unless init
|
10
|
+
open
|
11
|
+
else
|
12
|
+
self.init(source_repository)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def init(source_url)
|
17
|
+
@repo = Git.clone(source_url, @project_path.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def open
|
21
|
+
@repo = Git.open(@project_path)
|
22
|
+
@log = @repo.log
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
@repo.pull
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/dotter/gitrepo.rb
CHANGED
@@ -1,43 +1,52 @@
|
|
1
1
|
require 'git'
|
2
2
|
module Dotter
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
3
|
+
require 'dotter/utilities'
|
4
|
+
class GitRepo
|
5
|
+
include Utilities
|
6
|
+
def initialize(package, init = false, bare = false)
|
7
|
+
@package = package
|
8
|
+
@project_path = package_path(package)
|
9
|
+
@metadata_path = repo_path(package)
|
10
|
+
@metadata_indexes_path = index_path(package)
|
11
|
+
unless init
|
12
|
+
open
|
13
|
+
else
|
14
|
+
self.init(bare)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def open
|
19
|
+
@repo = Git.open(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s)
|
20
|
+
@log = @repo.log
|
21
|
+
end
|
22
|
+
|
23
|
+
def init(bare = false)
|
24
|
+
unless bare
|
25
|
+
@repo = Git.init(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s)
|
26
|
+
else
|
27
|
+
@repo = Git.init(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s, bare: true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
attr_reader :repo
|
31
|
+
attr_reader :project_path
|
32
|
+
attr_reader :package
|
33
|
+
attr_reader :metadata_path
|
34
|
+
attr_reader :metadata_indexes_path
|
35
|
+
attr_reader :log
|
36
|
+
def add(file)
|
37
|
+
@repo.add(file)
|
38
|
+
end
|
39
|
+
|
40
|
+
def reset
|
41
|
+
@repo.reset
|
42
|
+
end
|
43
|
+
|
44
|
+
def commit_all(commit_message)
|
45
|
+
@repo.commit_all(commit_message)
|
46
|
+
end
|
47
|
+
|
48
|
+
def commit(commit_message)
|
49
|
+
@repo.commit(commit_message)
|
50
|
+
end
|
51
|
+
end
|
43
52
|
end
|
data/lib/dotter/package.rb
CHANGED
@@ -1,60 +1,81 @@
|
|
1
1
|
require 'dotter/utilities'
|
2
2
|
require 'dotter/configuration'
|
3
3
|
require 'dotter/gitrepo'
|
4
|
+
require 'dotter/foreigngitrepo'
|
4
5
|
module Dotter
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
6
|
+
class Package
|
7
|
+
include Utilities
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
@config = Configuration.new
|
11
|
+
@our_config = @config.package_config(@name)
|
12
|
+
if self.tracked?
|
13
|
+
unless self.foreign?
|
14
|
+
@repo = GitRepo.new(name)
|
15
|
+
else
|
16
|
+
@repo = ForeignGitRepo.new(name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def stow
|
22
|
+
go_to_dotfiles
|
23
|
+
returned_output = `stow -v #{@name}`
|
24
|
+
@config.set_state(@name, 'stowed')
|
25
|
+
returned_output
|
26
|
+
end
|
27
|
+
|
28
|
+
def unstow
|
29
|
+
go_to_dotfiles
|
30
|
+
returned_output = `stow -Dv #{@name}`
|
31
|
+
@config.set_state(@name, 'unstowed')
|
32
|
+
returned_output
|
33
|
+
end
|
34
|
+
|
35
|
+
def track
|
36
|
+
@repo = GitRepo.new(@name, true)
|
37
|
+
@config.track(@name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update
|
41
|
+
go_to_dotfiles
|
42
|
+
@repo.update if self.foreign?
|
43
|
+
returned_output = `stow -Rv #{@name}`
|
44
|
+
end
|
45
|
+
|
46
|
+
def stowed?
|
47
|
+
@our_config['state'] == 'stowed'
|
48
|
+
end
|
49
|
+
|
50
|
+
def unstowed?
|
51
|
+
!self.stowed?
|
52
|
+
end
|
53
|
+
|
54
|
+
def tracked?
|
55
|
+
@our_config['tracked']
|
56
|
+
end
|
57
|
+
|
58
|
+
def untracked?
|
59
|
+
!self.tracked?
|
60
|
+
end
|
61
|
+
|
62
|
+
def foreign?
|
63
|
+
@our_config['type'] == 'git_repo'
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
@name
|
68
|
+
end
|
69
|
+
|
70
|
+
def public?
|
71
|
+
@our_config['public'] == true
|
72
|
+
end
|
73
|
+
|
74
|
+
def private?
|
75
|
+
!self.public?
|
76
|
+
end
|
77
|
+
attr_reader :name
|
78
|
+
attr_accessor :config
|
79
|
+
attr_reader :repo
|
80
|
+
end
|
60
81
|
end
|
data/lib/dotter/publicgitrepo.rb
CHANGED
@@ -2,41 +2,46 @@ require 'git'
|
|
2
2
|
require 'dotter/utilities'
|
3
3
|
require 'dotter/gitrepo'
|
4
4
|
module Dotter
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
5
|
+
class PublicGitRepo
|
6
|
+
include Utilities
|
7
|
+
def initialize(init = false)
|
8
|
+
@project_path = package_path('public')
|
9
|
+
unless init
|
10
|
+
open
|
11
|
+
else
|
12
|
+
self.init
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def open
|
17
|
+
@repo = Git.open(@project_path.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def init
|
21
|
+
@repo = Git.init(@project_path.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_package(package)
|
25
|
+
Dir.chdir(@project_path)
|
26
|
+
other_package = Package.new(package)
|
27
|
+
packagerepo = other_package.repo
|
28
|
+
package_repo = packagerepo.repo
|
29
|
+
@repo.add_remote(package.to_s, package_repo)
|
30
|
+
subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master`
|
31
|
+
conf = Configuration.new
|
32
|
+
conf.publish(package)
|
33
|
+
subtree_output
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_package(package)
|
37
|
+
Dir.chdir(@project_path)
|
38
|
+
# This was broken with ruby-git. Someone else should check.
|
39
|
+
`git remote remove #{package}`
|
40
|
+
FileUtils.remove_dir(package)
|
41
|
+
@repo.commit_all('Removed package #{package}')
|
42
|
+
conf = Configuration.new
|
43
|
+
conf.unpublish(package)
|
44
|
+
end
|
45
|
+
attr_reader :repo
|
46
|
+
end
|
42
47
|
end
|
data/lib/dotter/utilities.rb
CHANGED
@@ -1,34 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
require 'pathname'
|
2
|
+
module Dotter
|
3
|
+
module Utilities
|
4
|
+
@@dotfiles_path = Pathname(File.expand_path('~/dotfiles'))
|
5
|
+
def dotfiles_path
|
6
|
+
@@dotfiles_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def go_to_dotfiles
|
10
|
+
Dir.chdir(@@dotfiles_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def package_path(package)
|
14
|
+
@@dotfiles_path + package
|
15
|
+
end
|
16
|
+
@@dotter_path = @@dotfiles_path + 'dotter'
|
17
|
+
@@public_repo_path = @@dotfiles_path + 'public'
|
18
|
+
def dotter_path
|
19
|
+
@@dotter_path
|
20
|
+
end
|
21
|
+
|
22
|
+
def repo_path(package)
|
23
|
+
@@dotter_path + '.dotter/gitrepos/' + package
|
24
|
+
end
|
25
|
+
|
26
|
+
def index_path(package)
|
27
|
+
@@dotter_path + '.dotter/indexes/' + package
|
28
|
+
end
|
29
|
+
|
30
|
+
def all_package_names
|
31
|
+
directory = Pathname.new(@@dotfiles_path)
|
32
|
+
directories = directory.children.select(&:directory?)
|
33
|
+
package_names = []
|
34
|
+
directories.each do |directory|
|
35
|
+
package_names.push(directory.basename)
|
36
|
+
end
|
37
|
+
package_names
|
38
|
+
end
|
39
|
+
end
|
34
40
|
end
|
data/lib/dotter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotter_dotfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Hodgkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,9 +129,11 @@ executables:
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".codeclimate.yml"
|
132
133
|
- ".document"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".rdoc_options"
|
136
|
+
- ".rubocop.yml"
|
135
137
|
- ChangeLog.md
|
136
138
|
- Gemfile
|
137
139
|
- LICENSE.txt
|
@@ -142,6 +144,7 @@ files:
|
|
142
144
|
- lib/dotter.rb
|
143
145
|
- lib/dotter/cli.rb
|
144
146
|
- lib/dotter/configuration.rb
|
147
|
+
- lib/dotter/foreigngitrepo.rb
|
145
148
|
- lib/dotter/gitrepo.rb
|
146
149
|
- lib/dotter/package.rb
|
147
150
|
- lib/dotter/publicgitrepo.rb
|