Skip to content

Commit

Permalink
Move to Nwiki.get_head
Browse files Browse the repository at this point in the history
  • Loading branch information
niku committed Jul 15, 2017
1 parent 121017c commit 32e7430
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 12 additions & 1 deletion lib/nwiki.rb
@@ -1,5 +1,16 @@
require "nwiki/version"

module Nwiki
# Your code goes here...
class << self
def get_head(temporary_path, repo_url)
require "rugged"
if File.exist?(temporary_path)
repository = Rugged::Repository.discover(temporary_path)
repository.fetch("origin")
repository.reset("FETCH_HEAD", :hard)
else
Rugged::Repository.clone_at(repo_url, temporary_path)
end
end
end
end
11 changes: 3 additions & 8 deletions rakelib/nwiki.rake
@@ -1,6 +1,8 @@
require "rake/clean"
require "erb"

require "nwiki"

# An environment variable which is setted multibyte in Dockerhub get garbled.
# Workaround here
ENV["NWIKI_SITE_NAME"] = "ヽ(´・肉・`)ノログ"
Expand Down Expand Up @@ -44,14 +46,7 @@ __EOD__

desc "get head of a remote git repository"
task :get_head do
require "rugged"
if File.exist?(temporary_path)
repository = Rugged::Repository.discover(temporary_path)
repository.fetch("origin")
repository.reset("FETCH_HEAD", :hard)
else
Rugged::Repository.clone_at(ENV.fetch("NWIKI_REPO"), temporary_path)
end
Nwiki.get_head(temporary_path, ENV.fetch("NWIKI_REPO"))
end

desc "convert from org to html contents"
Expand Down

0 comments on commit 32e7430

Please sign in to comment.