diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-02-27 21:39:28 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-02-27 21:39:28 -0300 |
commit | e00add2a401920b5c21db57b5a8b2bcd5ae427f6 (patch) | |
tree | b8c5048bed65c12bea39d1b17a387a4f387c2ee0 /lib/keyring/repository.rb | |
parent | bcd9a028016c9b29533bc894796cdb0b7ea89ab0 (diff) | |
download | keyringer-e00add2a401920b5c21db57b5a8b2bcd5ae427f6.tar.gz keyringer-e00add2a401920b5c21db57b5a8b2bcd5ae427f6.tar.bz2 |
Init: setting folder structure and initial commmit
Diffstat (limited to 'lib/keyring/repository.rb')
-rw-r--r-- | lib/keyring/repository.rb | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/lib/keyring/repository.rb b/lib/keyring/repository.rb index 88d2b54..a9e0de5 100644 --- a/lib/keyring/repository.rb +++ b/lib/keyring/repository.rb @@ -25,32 +25,44 @@ module Keyring end # Check for a valid repository - # TODO: check for repository version, .git - # and configuration. def exists?(path) - File.directory?(path) + File.directory?(path + '/.git') + end + + def getConfigPath(path) + path + '/config' end def create(path, url = nil) - keys_path = Keys.getPath(path) - - if !exists?(path) - if url - @git.clone(url, path) - else - @git.init(path) - end + keys_path = Keys.getPath(path) + config_path = getConfigPath(path) + + if url + raise "Path #{path} exists and is a git repository" if exists?(path) + @git.clone(url, path) + else + @git.init(path) end + # Setup folders + FileUtils.mkdir_p keys_path + FileUtils.mkdir_p config_path + FileUtils.chmod(0700, path) + # Reparse basedir to force absolute folder path = Pathname.new(path).realpath + + # Create recipients + recipients = Keyring::Recipients.new(path) # TODO: if needed: - # create structure - # recipients, options, version, keys + # options, version, keys # save user config - # issue initial commit - # set permissions + + @git.add('.') + + # TODO: commit just if the repository status has changed + @git.commit('Importing') end end end |