dotter_dotfiles 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +11 -0
- data/.rdoc_options +16 -0
- data/ChangeLog.md +4 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.md +16 -0
- data/Rakefile +19 -0
- data/bin/dotter +16 -0
- data/dotter.gemspec +39 -0
- data/lib/dotter.rb +1 -0
- data/lib/dotter/cli.rb +185 -0
- data/lib/dotter/configuration.rb +39 -0
- data/lib/dotter/gitrepo.rb +43 -0
- data/lib/dotter/package.rb +60 -0
- data/lib/dotter/publicgitrepo.rb +42 -0
- data/lib/dotter/utilities.rb +25 -0
- data/lib/dotter/version.rb +4 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3256b80787b7b02945fff1db5d2fd45a0e3b8c1
|
4
|
+
data.tar.gz: 8d04cbd1f070d83d568f7a80ec053fd5511ec8f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ce81490651bfc0e09bd428afdc61568f0576ddc9b502b0a294a0230ee258c56054bd43da60c20f19de60907759d9cd7b0e9cb50d3b50c43ad8587c877c866ba
|
7
|
+
data.tar.gz: 500df8b98f9558054e4218c449158046fb38667d42c79a772a46d6947e2585ee036b242ea3950b265d8650481994cb72b3f0c01a0da07d604fb3948bd7a9b238
|
data/.document
ADDED
data/.gitignore
ADDED
data/.rdoc_options
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
--- !ruby/object:RDoc::Options
|
2
|
+
encoding: UTF-8
|
3
|
+
static_path: []
|
4
|
+
rdoc_include:
|
5
|
+
- .
|
6
|
+
charset: UTF-8
|
7
|
+
exclude:
|
8
|
+
hyperlink_all: false
|
9
|
+
line_numbers: false
|
10
|
+
main_page: README.md
|
11
|
+
markup: markdown
|
12
|
+
show_hash: false
|
13
|
+
tab_width: 8
|
14
|
+
title: dotter Documentation
|
15
|
+
visibility: :protected
|
16
|
+
webcvs:
|
data/ChangeLog.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Samuel Hodgkins
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Dotter, a dotfiles manager using stow & git
|
2
|
+
|
3
|
+
As the title explained, dotter is a tool to manage your dotfiles. It is written in ruby and uses the tools stow and git in order to manage your dotfiles effectively.
|
4
|
+
It wraps around both tools in order to achieve easy and effective management of dotfiles. Stow handles the symlinking of them while Git tracks the history.
|
5
|
+
It is very new, unfinished software that likely has multiple bugs. However, due to the specific tools used there is not too much risk with using it.
|
6
|
+
|
7
|
+
It is not yet published to rubygems but you can install the required dependencies via bundler.
|
8
|
+
|
9
|
+
To see all available commands, use `dotter help`. Not all commands are currently implemented.
|
10
|
+
|
11
|
+
## TODO
|
12
|
+
1. Refactor and clean up the code.
|
13
|
+
2. Implement all unimplemented commands.
|
14
|
+
3. Implement error handling
|
15
|
+
4. Add any useful suggested features.
|
16
|
+
5. Port to Crystal so it can be a single executable.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler/setup'
|
7
|
+
rescue LoadError => e
|
8
|
+
abort e.message
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'rake'
|
12
|
+
|
13
|
+
|
14
|
+
require 'rubygems/tasks'
|
15
|
+
Gem::Tasks.new
|
16
|
+
|
17
|
+
require 'rdoc/task'
|
18
|
+
RDoc::Task.new
|
19
|
+
task :doc => :rdoc
|
data/bin/dotter
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
root = File.expand_path(File.join(File.dirname(__FILE__),'..'))
|
4
|
+
if File.directory?(File.join(root,'.git'))
|
5
|
+
Dir.chdir(root) do
|
6
|
+
begin
|
7
|
+
require 'bundler/setup'
|
8
|
+
rescue LoadError => e
|
9
|
+
warn e.message
|
10
|
+
warn "Run `gem install bundler` to install Bundler"
|
11
|
+
exit -1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
require 'dotter/cli'
|
16
|
+
Dotter::CLI.start(ARGV)
|
data/dotter.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'dotter/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "dotter_dotfiles"
|
9
|
+
gem.version = Dotter::VERSION
|
10
|
+
gem.summary = %q{A dotfiles managaer}
|
11
|
+
gem.description = %q{A simple, yet powerful dotfiles manager that wraps around stow and git}
|
12
|
+
gem.license = "MIT"
|
13
|
+
gem.authors = ["Samuel Hodgkins"]
|
14
|
+
gem.email = "samuel.hodgkins@sky.com"
|
15
|
+
gem.homepage = "https://rubygems.org/gems/dotter_dotfiles"
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
|
19
|
+
`git submodule --quiet foreach --recursive pwd`.split($/).each do |submodule|
|
20
|
+
submodule.sub!("#{Dir.pwd}/",'')
|
21
|
+
|
22
|
+
Dir.chdir(submodule) do
|
23
|
+
`git ls-files`.split($/).map do |subpath|
|
24
|
+
gem.files << File.join(submodule,subpath)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
29
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
30
|
+
gem.require_paths = ['lib']
|
31
|
+
|
32
|
+
gem.add_development_dependency 'bundler', '~> 1.10'
|
33
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
gem.add_development_dependency 'rdoc', '~> 4.0'
|
35
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
36
|
+
gem.add_runtime_dependency 'thor'
|
37
|
+
gem.add_runtime_dependency 'git'
|
38
|
+
gem.add_runtime_dependency 'inifile'
|
39
|
+
end
|
data/lib/dotter.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'dotter/version'
|
data/lib/dotter/cli.rb
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'dotter/utilities'
|
3
|
+
require 'dotter/gitrepo'
|
4
|
+
require 'dotter/version'
|
5
|
+
require 'dotter/configuration'
|
6
|
+
require 'dotter/package'
|
7
|
+
require 'dotter/publicgitrepo'
|
8
|
+
require 'pathname'
|
9
|
+
module Dotter
|
10
|
+
class CLI < Thor
|
11
|
+
include Utilities
|
12
|
+
desc "version", "Print the dotter version"
|
13
|
+
def version
|
14
|
+
puts "This is dotter #{Dotter::VERSION}"
|
15
|
+
end
|
16
|
+
desc "init", "Initialise the directory structure for ~/dotfiles"
|
17
|
+
def init
|
18
|
+
puts "Initialising ~/dotfiles"
|
19
|
+
puts "Creating the dotfiles directory."
|
20
|
+
FileUtils.mkpath(dotfiles_path)
|
21
|
+
go_to_dotfiles
|
22
|
+
puts "Creating the directory for the combined public dotfiles."
|
23
|
+
FileUtils.mkpath('public')
|
24
|
+
puts "Creating an initial package for dotter."
|
25
|
+
FileUtils.mkpath('dotter/.dotter/gitrepos')
|
26
|
+
FileUtils.mkpath('dotter/.dotter/indexes/')
|
27
|
+
end
|
28
|
+
desc "list", "List all packages present in ~/dotfiles"
|
29
|
+
def list
|
30
|
+
puts "List of packages in ~/dotfiles"
|
31
|
+
directory_name = dotfiles_path
|
32
|
+
directory = Pathname.new(directory_name)
|
33
|
+
directories = directory.children.select { |c| c.directory? }
|
34
|
+
package_names = []
|
35
|
+
directories.each do |directory|
|
36
|
+
package_names.push(directory.basename)
|
37
|
+
end
|
38
|
+
package_names.each do |package|
|
39
|
+
puts package
|
40
|
+
end
|
41
|
+
end
|
42
|
+
desc "stow PACKAGE", "Stow the given package name."
|
43
|
+
def stow(package)
|
44
|
+
package = Package.new(package)
|
45
|
+
if package.stowed?
|
46
|
+
error "Package #{package} is already stowed."
|
47
|
+
exit(1)
|
48
|
+
end
|
49
|
+
puts "Stowing package #{package}"
|
50
|
+
puts package.stow
|
51
|
+
end
|
52
|
+
desc "unstow PACKAGE", "Unstow the given package name."
|
53
|
+
def unstow(package)
|
54
|
+
package = Package.new(package)
|
55
|
+
if package.unstowed?
|
56
|
+
error "Package #{package} is not stowed."
|
57
|
+
exit(1)
|
58
|
+
end
|
59
|
+
puts "Unstowing package #{package}"
|
60
|
+
puts package.unstow
|
61
|
+
end
|
62
|
+
desc "track PACKAGE", "Begin tracking the given package with Git"
|
63
|
+
def track(package)
|
64
|
+
puts "Initialising Git repository for package #{package}"
|
65
|
+
package = Package.new(package)
|
66
|
+
package.track
|
67
|
+
puts "Repository for package #{package} initialised. Git's metadata is stored in #{package.repo.metadata_path.to_s}"
|
68
|
+
puts "Creating an initial snapshot to serve as a starting point."
|
69
|
+
repo = package.repo
|
70
|
+
repo.add('.')
|
71
|
+
repo.commit_all("Initial snapshot of the package's contents")
|
72
|
+
puts "Initial snapshot created."
|
73
|
+
end
|
74
|
+
desc "publish PACKAGE", "Make a package available in your public dotfiles repository"
|
75
|
+
def publish(package)
|
76
|
+
puts "Making package #{package} public"
|
77
|
+
public_repo = PublicGitRepo.new
|
78
|
+
puts public_repo.add_package(package)
|
79
|
+
end
|
80
|
+
desc "unpublish PACKAGE", "Make a package private after publishing it."
|
81
|
+
def unpublish(package)
|
82
|
+
puts "Making package #{package} private again"
|
83
|
+
public_repo = PublicGitRepo.new
|
84
|
+
public_repo.remove_package(package)
|
85
|
+
end
|
86
|
+
method_option :commit_message, :required => true, :aliases => "-m"
|
87
|
+
method_option :all, :type => :boolean, :aliases => "-a"
|
88
|
+
desc "commit PACKAGE", "Commit your changes to a Git-tracked package."
|
89
|
+
def commit(package)
|
90
|
+
package = Package.new(package)
|
91
|
+
if package.untracked?
|
92
|
+
error "Package #{package} is not tracked by Git."
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
puts "Committing the changes to package #{package} with commit message #{options.commit_message}."
|
96
|
+
commit_message = options.commit_message
|
97
|
+
repo = package.repo
|
98
|
+
if options.all
|
99
|
+
repo.commit_all(commit_message)
|
100
|
+
else
|
101
|
+
repo.commit(commit_message)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
desc "update PACKAGE", "Updates the specified package"
|
105
|
+
def update(package)
|
106
|
+
puts "Updating the contents / symlinks for package #{package}"
|
107
|
+
package = Package.new(package)
|
108
|
+
if package.unstowed?
|
109
|
+
error "Package #{package} is not stowed and therefore cannot be updated."
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
package.update
|
113
|
+
end
|
114
|
+
desc "update_all", "Updates all stowed packages."
|
115
|
+
def update_all()
|
116
|
+
puts "Updating all stowed packages"
|
117
|
+
end
|
118
|
+
desc "import PATH PACKAGE", "Imports a file or directory into the specified package"
|
119
|
+
def import(path, package)
|
120
|
+
puts "Importing #{path} into package {package}"
|
121
|
+
filepath = Pathname.new(File.expand_path(path))
|
122
|
+
packagepath = package_path(package)
|
123
|
+
homepath = Pathname.new(File.expand_path('~'))
|
124
|
+
relative_filepath = filepath.relative_path_from(homepath)
|
125
|
+
complete_path = packagepath + relative_filepath
|
126
|
+
FileUtils.copy(File.expand_path(path), complete_path.to_s)
|
127
|
+
puts "File imported successfully. Update the package to make the symlink."
|
128
|
+
end
|
129
|
+
desc "import_repo REPO_URL PACKAGE", "Clones the specified git repository as the contents of the specified Package."
|
130
|
+
def import_repo(repo_url, package)
|
131
|
+
puts "Cloning repository #{repo_url} into package #{package}"
|
132
|
+
end
|
133
|
+
desc "clone REPO_URL", "Clones the dotfiles / packages of the specified repository into ~/dotfiles. Will overwrite any existing data."
|
134
|
+
def clone(repo_url)
|
135
|
+
puts "Cloning repository #{repo_url} directly into ~/dotfiles"
|
136
|
+
end
|
137
|
+
desc "status PACKAGE", "Obtain the repository status of a Git-tracked package."
|
138
|
+
def status(package)
|
139
|
+
package = Package.new(package)
|
140
|
+
if package.untracked?
|
141
|
+
error "Package #{package} is not tracked by Git."
|
142
|
+
exit 1
|
143
|
+
end
|
144
|
+
metadata_path = repo_path(package.to_s)
|
145
|
+
metadata_indexes_path = index_path(package.to_s)
|
146
|
+
# Punt because it does this better than ruby-git.
|
147
|
+
system({"GIT_DIR" => metadata_path.to_s, "GIT_INDEX_FILE" => metadata_indexes_path.to_s}, "git status")
|
148
|
+
end
|
149
|
+
desc "add PACKAGE FILE", "Add a file from a package to the next commit of that package."
|
150
|
+
def add(package,file)
|
151
|
+
package = Package.new(package)
|
152
|
+
if package.untracked?
|
153
|
+
error "Package #{package} is not tracked by Git."
|
154
|
+
exit 1
|
155
|
+
end
|
156
|
+
puts "Marking #{file} to be committed for package #{package}"
|
157
|
+
repo = package.repo
|
158
|
+
repo.add(file)
|
159
|
+
end
|
160
|
+
desc "reset PACKAGE", "Reset what will be commmitted in the next commit to the given package."
|
161
|
+
def reset(package)
|
162
|
+
package = Package.new(package)
|
163
|
+
if package.untracked?
|
164
|
+
error "Package #{package} is not tracked by Git."
|
165
|
+
exit 1
|
166
|
+
end
|
167
|
+
puts "Resetting what will be committed to package #{package}"
|
168
|
+
repo = package.repo
|
169
|
+
repo.reset()
|
170
|
+
end
|
171
|
+
desc "log PACKAGE", "View the commit log of a package."
|
172
|
+
def log(package)
|
173
|
+
package = Package.new(package)
|
174
|
+
if package.untracked?
|
175
|
+
error "Package #{package} is not tracked by Git."
|
176
|
+
exit 1
|
177
|
+
end
|
178
|
+
puts "Obtaining the log of package #{package}"
|
179
|
+
repo = package.repo
|
180
|
+
repo.log.each do |commit|
|
181
|
+
puts "[#{commit.date}] #{commit.message} (#{commit.author.name})"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'dotter/utilities'
|
2
|
+
require 'inifile'
|
3
|
+
module Dotter
|
4
|
+
class Configuration
|
5
|
+
include Utilities
|
6
|
+
attr_reader :config_file
|
7
|
+
attr_accessor :config
|
8
|
+
def initialize(config_file=package_path('dotter') + '.dotter/Dotfile')
|
9
|
+
@config_file = config_file
|
10
|
+
@config = IniFile.load(config_file)
|
11
|
+
end
|
12
|
+
def package_config(package)
|
13
|
+
@config[package]
|
14
|
+
end
|
15
|
+
def save()
|
16
|
+
@config.write()
|
17
|
+
end
|
18
|
+
def set_state(package, state)
|
19
|
+
package_conf = self.package_config(package)
|
20
|
+
package_conf['state'] = state
|
21
|
+
self.save()
|
22
|
+
end
|
23
|
+
def track(package)
|
24
|
+
package_conf = self.package_config(package)
|
25
|
+
package_conf['tracked'] = true
|
26
|
+
self.save()
|
27
|
+
end
|
28
|
+
def publish(package)
|
29
|
+
package_conf = self.package_config(package)
|
30
|
+
package_conf['public'] = true
|
31
|
+
self.save()
|
32
|
+
end
|
33
|
+
def unpublish(package)
|
34
|
+
package_conf = self.package_config(package)
|
35
|
+
package_conf['public'] = false
|
36
|
+
self.save()
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'git'
|
2
|
+
module Dotter
|
3
|
+
require 'dotter/utilities'
|
4
|
+
class GitRepo
|
5
|
+
include Utilities
|
6
|
+
def initialize(package,init=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
|
+
self.open()
|
13
|
+
else
|
14
|
+
self.init()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def open()
|
18
|
+
@repo = Git.open(@project_path.to_s, { :repository => @metadata_path.to_s, :index => @metadata_indexes_path.to_s})
|
19
|
+
@log = @repo.log
|
20
|
+
end
|
21
|
+
def init()
|
22
|
+
@repo = Git.init(@project_path.to_s, { :repository => @metadata_path.to_s, :index => @metadata_indexes_path.to_s})
|
23
|
+
end
|
24
|
+
attr_reader :repo
|
25
|
+
attr_reader :project_path
|
26
|
+
attr_reader :package
|
27
|
+
attr_reader :metadata_path
|
28
|
+
attr_reader :metadata_indexes_path
|
29
|
+
attr_reader :log
|
30
|
+
def add(file)
|
31
|
+
@repo.add(file)
|
32
|
+
end
|
33
|
+
def reset()
|
34
|
+
@repo.reset()
|
35
|
+
end
|
36
|
+
def commit_all(commit_message)
|
37
|
+
@repo.commit_all(commit_message)
|
38
|
+
end
|
39
|
+
def commit(commit_message)
|
40
|
+
@repo.commit(commit_message)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'dotter/utilities'
|
2
|
+
require 'dotter/configuration'
|
3
|
+
require 'dotter/gitrepo'
|
4
|
+
module Dotter
|
5
|
+
class Package
|
6
|
+
include Utilities
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@config = Configuration.new
|
10
|
+
@our_config = @config.package_config(@name)
|
11
|
+
if self.tracked?
|
12
|
+
@repo = GitRepo.new(name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def stow
|
16
|
+
go_to_dotfiles
|
17
|
+
returned_output = `stow -v #{@name}`
|
18
|
+
@config.set_state(@name, 'stowed')
|
19
|
+
returned_output
|
20
|
+
end
|
21
|
+
def unstow
|
22
|
+
go_to_dotfiles
|
23
|
+
returned_output = `stow -Dv #{@name}`
|
24
|
+
@config.set_state(@name, 'unstowed')
|
25
|
+
returned_output
|
26
|
+
end
|
27
|
+
def track
|
28
|
+
@repo = GitRepo.new(@name,true)
|
29
|
+
@config.track(@name)
|
30
|
+
end
|
31
|
+
def update
|
32
|
+
go_to_dotfiles
|
33
|
+
returned_output = `stow -Rv #{@name}`
|
34
|
+
end
|
35
|
+
def stowed?
|
36
|
+
@our_config['state'] == 'stowed'
|
37
|
+
end
|
38
|
+
def unstowed?
|
39
|
+
!self.stowed?
|
40
|
+
end
|
41
|
+
def tracked?
|
42
|
+
@our_config['tracked']
|
43
|
+
end
|
44
|
+
def untracked?
|
45
|
+
!self.tracked?
|
46
|
+
end
|
47
|
+
def to_s
|
48
|
+
@name
|
49
|
+
end
|
50
|
+
def public?
|
51
|
+
@our_config['public'] = true
|
52
|
+
end
|
53
|
+
def private?
|
54
|
+
!self.public?
|
55
|
+
end
|
56
|
+
attr_reader :name
|
57
|
+
attr_accessor :config
|
58
|
+
attr_reader :repo
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'dotter/utilities'
|
3
|
+
require 'dotter/gitrepo'
|
4
|
+
module Dotter
|
5
|
+
class PublicGitRepo
|
6
|
+
include Utilities
|
7
|
+
def initialize(init=false)
|
8
|
+
@project_path = package_path('public')
|
9
|
+
unless init
|
10
|
+
self.open()
|
11
|
+
else
|
12
|
+
self.init()
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def open
|
16
|
+
@repo = Git.open(@project_path.to_s)
|
17
|
+
end
|
18
|
+
def init
|
19
|
+
@repo = Git.init(@project_path.to_s)
|
20
|
+
end
|
21
|
+
def add_package(package)
|
22
|
+
Dir.chdir(@project_path)
|
23
|
+
packagerepo = GitRepo.new(package)
|
24
|
+
package_repo = packagerepo.repo
|
25
|
+
@repo.add_remote(package.to_s, package_repo)
|
26
|
+
subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master`
|
27
|
+
conf = Configuration.new
|
28
|
+
conf.publish(package)
|
29
|
+
subtree_output
|
30
|
+
end
|
31
|
+
def remove_package(package)
|
32
|
+
Dir.chdir(@project_path)
|
33
|
+
# This was broken with ruby-git. Someone else should check.
|
34
|
+
`git remote remove #{package}`
|
35
|
+
FileUtils.remove_dir(package)
|
36
|
+
@repo.commit_all('Removed package #{package}')
|
37
|
+
conf = Configuration.new
|
38
|
+
conf.unpublish(package)
|
39
|
+
end
|
40
|
+
attr_reader :repo
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
def go_to_dotfiles()
|
9
|
+
Dir.chdir(@@dotfiles_path)
|
10
|
+
end
|
11
|
+
def package_path(package)
|
12
|
+
@@dotfiles_path + package
|
13
|
+
end
|
14
|
+
@@dotter_path = @@dotfiles_path + 'dotter'
|
15
|
+
def dotter_path
|
16
|
+
@@dotter_path
|
17
|
+
end
|
18
|
+
def repo_path(package)
|
19
|
+
@@dotter_path + '.dotter/gitrepos/' + package
|
20
|
+
end
|
21
|
+
def index_path(package)
|
22
|
+
@@dotter_path + '.dotter/indexes/' + package
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dotter_dotfiles
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Hodgkins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-31 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: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubygems-tasks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: git
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: inifile
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A simple, yet powerful dotfiles manager that wraps around stow and git
|
112
|
+
email: samuel.hodgkins@sky.com
|
113
|
+
executables:
|
114
|
+
- dotter
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".document"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rdoc_options"
|
121
|
+
- ChangeLog.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/dotter
|
127
|
+
- dotter.gemspec
|
128
|
+
- lib/dotter.rb
|
129
|
+
- lib/dotter/cli.rb
|
130
|
+
- lib/dotter/configuration.rb
|
131
|
+
- lib/dotter/gitrepo.rb
|
132
|
+
- lib/dotter/package.rb
|
133
|
+
- lib/dotter/publicgitrepo.rb
|
134
|
+
- lib/dotter/utilities.rb
|
135
|
+
- lib/dotter/version.rb
|
136
|
+
homepage: https://rubygems.org/gems/dotter_dotfiles
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.4.5.1
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: A dotfiles managaer
|
160
|
+
test_files: []
|