setup git repo fixtures

This commit is contained in:
Rick Olson 2014-05-28 14:26:25 -06:00
parent 7316645730
commit f7cc510d3c
12 changed files with 107 additions and 8 deletions

@ -0,0 +1 @@
ref: refs/heads/master

@ -0,0 +1,7 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true

@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

@ -0,0 +1,54 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0

@ -0,0 +1 @@
0000000000000000000000000000000000000000 00df65f30b769b694e2a1ca57e054d45d3d8bf9b Rick Olson <technoweenie@gmail.com> 1401306971 -0600 commit (initial): add .gitconfig

@ -0,0 +1 @@
0000000000000000000000000000000000000000 00df65f30b769b694e2a1ca57e054d45d3d8bf9b Rick Olson <technoweenie@gmail.com> 1401306971 -0600 commit (initial): add .gitconfig

@ -0,0 +1,2 @@
x<01>Í[
à @Ñ~»ŠÙ@ƒ&ñ¡t…îÀŒ£FRK·ß¬¡¿¹ÖÒA9}éÌät²n¤HÑÛirkÔ&Y=&¯µ5¥Y=*/§o|À³à û›,<2C>pkü%j…²ÈõjjÆ[Wi¤g=§<>þä"ÄC.¹¥’Å;ð<O

@ -0,0 +1 @@
00df65f30b769b694e2a1ca57e054d45d3d8bf9b

@ -1,4 +1,5 @@
require "tmpdir" require "tmpdir"
require "fileutils"
class Suite class Suite
class Config < Struct.new(:root) class Config < Struct.new(:root)
@ -45,18 +46,46 @@ class Suite
@tests ||= [] @tests ||= []
end end
def self.test_tmpdir
@test_tmpdir ||= File.join(config.tmp, "git-media-tests")
end
FileUtils.rm_rf(test_tmpdir)
# Gets the global git configuration.
def self.global_git_config def self.global_git_config
`git config -l --global`.strip.split("\n") `git config -l --global`.strip.split("\n")
end end
# Clones the sample repository to a test
def self.repository(name)
path = File.join(config.root, "integration", "repos", name.to_s)
if !File.exist?(path)
path += ".git"
end
if !File.exist?(path)
raise ArgumentError, "No example repository #{name} (#{path.inspect})"
end
dest = File.join(test_tmpdir, name.to_s)
Dir.chdir File.join(config.root, "integration", "repos") do
%x{git clone #{name} #{dest}}
end
dest
end
def self.test(repository) def self.test(repository)
t = Test.new(repository, "#{repository}/.git") t = Test.new(repository)
yield t if block_given? yield t if block_given?
tests << t tests << t
end end
class Test class Test
attr_reader :path
def initialize(*repositories) def initialize(*repositories)
@path = repositories.first
@repositories = repositories @repositories = repositories
@commands = [] @commands = []
@successful = true @successful = true
@ -136,5 +165,6 @@ class Suite
if tests.any?(&:failed?) if tests.any?(&:failed?)
abort "Failed." abort "Failed."
end end
FileUtils.remove_entry_secure(test_tmpdir)
end end
end end

@ -2,7 +2,8 @@ require File.expand_path("../suite", __FILE__)
config = Suite.config config = Suite.config
Suite.test config.root do |t| Suite.test config.root do |t|
t.repository File.join(config.root, "integration") # sub directory! t.repository File.join(t.path, ".git")
t.repository File.join(t.path, "integration") # sub directory!
# really simple test # really simple test
t.command "version", t.command "version",
@ -18,9 +19,9 @@ Nothing may see Gah Lak Tus and survive.
t.command "config", t.command "config",
<<-END <<-END
Endpoint=https://github.com/github/git-media.git/info/media Endpoint=https://github.com/github/git-media.git/info/media
LocalWorkingDir=#{config.root} LocalWorkingDir=#{t.path}
LocalGitDir=#{File.join config.root, ".git"} LocalGitDir=#{File.join t.path, ".git"}
LocalMediaDir=#{File.join config.root, ".git", "media"} LocalMediaDir=#{File.join t.path, ".git", "media"}
TempDir=#{File.join config.tmp, "git-media"} TempDir=#{File.join config.tmp, "git-media"}
#{config.env_string} #{config.env_string}
END END
@ -52,9 +53,9 @@ Suite.test Suite.repository(:config_media_url) do |t|
t.command "config", t.command "config",
<<-END <<-END
Endpoint=http://foo/bar Endpoint=http://foo/bar
LocalWorkingDir=#{config.root} LocalWorkingDir=#{File.join "/private", t.path}
LocalGitDir=#{File.join config.root, ".git"} LocalGitDir=#{File.join "/private", t.path, ".git"}
LocalMediaDir=#{File.join config.root, ".git", "media"} LocalMediaDir=#{File.join "/private", t.path, ".git", "media"}
TempDir=#{File.join config.tmp, "git-media"} TempDir=#{File.join config.tmp, "git-media"}
#{config.env_string} #{config.env_string}
END END