put test repos in a better location, fix other bugs

This commit is contained in:
Sami Samhuri 2014-10-18 02:34:58 -07:00
parent 3437b8f08a
commit 291e40f859
9 changed files with 33 additions and 9 deletions

2
.gitignore vendored
View file

@ -3,4 +3,4 @@ node_modules
public/feed.xml
www
server/auth.json
server/spec/test-blog*
server/test-blog*

View file

@ -1,8 +1,12 @@
source 'https://rubygems.org'
gem 'builder'
gem 'css_parser'
gem 'htmlentities'
gem 'mustache'
gem 'nokogiri'
gem 'rdiscount'
gem 'sinatra'
gem 'rspec'
gem 'guard-rspec'

View file

@ -1,10 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.6)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
css_parser (1.3.5)
addressable
diff-lcs (1.2.5)
ffi (1.9.3)
formatador (0.2.5)
@ -25,6 +28,10 @@ GEM
rb-inotify (>= 0.9)
lumberjack (1.0.9)
method_source (0.8.2)
mini_portile (0.6.0)
mustache (0.99.6)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@ -63,8 +70,11 @@ PLATFORMS
DEPENDENCIES
builder
css_parser
guard-rspec
htmlentities
mustache
nokogiri
rdiscount
rspec
sinatra

View file

@ -13,7 +13,10 @@ publish_beta: compile
./bin/publish.sh --beta --delete
test_blog:
./bin/create-test-blog.sh server/spec/test-blog
./bin/create-test-blog.sh server/test-blog
clean:
rm -rf server/test-blog server/test-blog-origin.git
spec:
cd server && rspec -f documentation

View file

@ -9,7 +9,7 @@ if [[ -e "$BLOG_PATH" ]]; then
else
if [[ ! -e "$ORIGIN_BLOG_PATH" ]]; then
echo ">>> Mirroring local origin..."
git clone --mirror https://github.com/samsonjs/samhuri.net.git "$ORIGIN_BLOG_PATH"
git clone --mirror . "$ORIGIN_BLOG_PATH"
fi
echo ">>> Cloning test blog from local origin..."
git clone "$ORIGIN_BLOG_PATH" "$BLOG_PATH"

View file

@ -122,7 +122,7 @@ class HarpBlog
def posts_for_month(year, month)
post_dir = post_path(year, month)
post_data = read_post_data(post_dir)
post_data.values.sort_by {|p| p['timestamp'] }.map {|p| Post.new(p) }
post_data.values.sort_by { |p| p['timestamp'] }.map { |p| Post.new(p) }
end
def get_post(year, month, slug)

View file

@ -11,7 +11,7 @@ require './harp_blog'
$config = {
auth: false,
dry_run: false,
path: File.expand_path('../spec/test-blog', __FILE__),
path: File.expand_path('../test-blog', __FILE__),
host: '127.0.0.1',
port: 6706,
}

View file

@ -2,8 +2,8 @@ require 'json'
require_relative './helpers'
require_relative '../harp_blog'
TEST_BLOG_PATH = File.expand_path('../test-blog', __FILE__)
TEST_BLOG_ORIGIN_PATH = File.expand_path('../test-blog-origin.git', __FILE__)
TEST_BLOG_PATH = File.expand_path('../../test-blog', __FILE__)
TEST_BLOG_ORIGIN_PATH = File.expand_path('../../test-blog-origin.git', __FILE__)
RSpec.configure do |c|
c.include Helpers
@ -238,6 +238,7 @@ RSpec.describe HarpBlog do
blog = HarpBlog.new(TEST_BLOG_PATH, dry_run, TitleFinder.new)
post = blog.create_post(nil, nil, 'http://samhuri.net')
expect(post.title).to eq('fancy title')
blog.delete_post(post.time.year.to_s, post.padded_month, post.slug)
post = blog.create_post(" \t\n", nil, 'http://samhuri.net')
expect(post.title).to eq('fancy title')
end

View file

@ -16,7 +16,13 @@ module Helpers
end
def git_bare?(dir)
!File.exist?(File.join(dir, '.git'))
if File.exist?(File.join(dir, '.git'))
false
elsif File.exist?(File.join(dir, 'HEAD'))
true
else
raise "what is this dir? #{dir} #{Dir[dir + '/*'].join(', ')}"
end
end
def git_sha(dir)
@ -29,7 +35,7 @@ module Helpers
def git_reset_hard(dir, ref = nil)
if git_bare?(dir)
raise 'git_reset_hard does not support bare repos'
raise 'git_reset_hard does not support bare repos ' + dir + ' -- ' + ref.to_s
else
args = ref ? "'#{ref}'" : ''
`cd '#{dir}' && git reset --hard #{args}`