summaryrefslogtreecommitdiff
path: root/lib
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
parentb8443a9c8466e80098a649c86d6cdbe1ad31cf57 (diff)
downloadgitlab-shell-487b1bf271907e04701fd8a750d194a5b06eb4c0.tar.gz
Enable git-annex on first command
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_projects.rb5
-rw-r--r--lib/gitlab_shell.rb23
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 59a9347..05ee211 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -238,9 +238,4 @@ class GitlabProjects
$logger.info "Update head in project #{project_name} to <#{new_head}>."
true
end
-
- def git_init_annex
- cmd = %W(git --git-dir=#{full_path} annex init "GitLab")
- system(*cmd)
- end
end
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