lib/dotter/publicgitrepo.rb in dotter_dotfiles-0.2.0 vs lib/dotter/publicgitrepo.rb in dotter_dotfiles-0.3.0

- old
+ new

@@ -1,42 +1,47 @@ require 'git' require 'dotter/utilities' require 'dotter/gitrepo' module Dotter - class PublicGitRepo - include Utilities - def initialize(init=false) - @project_path = package_path('public') - unless init - self.open() - else - self.init() - end - end - def open - @repo = Git.open(@project_path.to_s) - end - def init - @repo = Git.init(@project_path.to_s) - end - def add_package(package) - Dir.chdir(@project_path) - packagerepo = GitRepo.new(package) - package_repo = packagerepo.repo - @repo.add_remote(package.to_s, package_repo) - subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master` - conf = Configuration.new - conf.publish(package) - subtree_output - end - def remove_package(package) - Dir.chdir(@project_path) - # This was broken with ruby-git. Someone else should check. - `git remote remove #{package}` - FileUtils.remove_dir(package) - @repo.commit_all('Removed package #{package}') - conf = Configuration.new - conf.unpublish(package) - end - attr_reader :repo - end + class PublicGitRepo + include Utilities + def initialize(init = false) + @project_path = package_path('public') + unless init + open + else + self.init + end + end + + def open + @repo = Git.open(@project_path.to_s) + end + + def init + @repo = Git.init(@project_path.to_s) + end + + def add_package(package) + Dir.chdir(@project_path) + other_package = Package.new(package) + packagerepo = other_package.repo + package_repo = packagerepo.repo + @repo.add_remote(package.to_s, package_repo) + subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master` + conf = Configuration.new + conf.publish(package) + subtree_output + end + + def remove_package(package) + Dir.chdir(@project_path) + # This was broken with ruby-git. Someone else should check. + `git remote remove #{package}` + FileUtils.remove_dir(package) + @repo.commit_all('Removed package #{package}') + conf = Configuration.new + conf.unpublish(package) + end + attr_reader :repo + end end