summaryrefslogtreecommitdiff
path: root/lib/gitlab_shell.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-13 16:52:45 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-13 16:53:27 -0800
commit487b1bf271907e04701fd8a750d194a5b06eb4c0 (patch)
treee00acd7dd929d3ffedb636acf7277fdfa968a7ff /lib/gitlab_shell.rb
parentb8443a9c8466e80098a649c86d6cdbe1ad31cf57 (diff)
downloadgitlab-shell-487b1bf271907e04701fd8a750d194a5b06eb4c0.tar.gz
Enable git-annex on first command
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r--lib/gitlab_shell.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 596c82e..98a5cbc 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -48,20 +48,15 @@ class GitlabShell
def parse_cmd
args = Shellwords.shellwords(@origin_cmd)
-
- if args.first == 'git-annex-shell'
- # Dont know yet how much arguments allow
- # puts args.count
- # puts args.inspect
- else
- raise DisallowedCommandError unless args.count == 2
- end
-
@git_cmd = args.first
if @git_cmd == 'git-annex-shell'
@repo_name = escape_path(args[2].gsub("\/~\/", ''))
+
+ # Make sure repository has git-annex enabled
+ enable_git_annex(@repo_name)
else
+ raise DisallowedCommandError unless args.count == 2
@repo_name = escape_path(args.last)
end
end
@@ -131,4 +126,14 @@ class GitlabShell
abort "Wrong repository path"
end
end
+
+ def enable_git_annex(path)
+ full_repo_path = File.join(repos_path, path)
+
+ unless File.exists?(File.join(full_repo_path, '.git', 'annex'))
+ cmd = %W(git --git-dir=#{full_repo_path} annex init "GitLab")
+ system(*cmd)
+ $logger.info "Enable git-annex for repository: #{path}."
+ end
+ end
end