Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Repository class for managing repositories.
- Let the repository recognize the SCM type - Add an SVN repository to test/repositories - Failed to add a Git repository to test/repositories, figure that out later
- Loading branch information
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
require 'optparse' | ||
|
||
require 'hail/workbench' | ||
require 'hail/repository' | ||
|
||
module Hail | ||
VERSION = '0.6.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Hail | ||
class Repository | ||
attr_accessor :directory | ||
|
||
def initialize(options={}) | ||
@directory = options[:directory] | ||
end | ||
|
||
def scm | ||
self.class.recognize_scm(directory) | ||
end | ||
|
||
def self.recognize_scm(directory) | ||
if File.exist?(File.join(directory, '.git')) | ||
'git' | ||
elsif File.exist?(File.join(directory, '.svn')) | ||
'svn' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require File.expand_path('../helper.rb', __FILE__) | ||
|
||
describe "Repository" do | ||
it "should recognize git repositories" do | ||
Hail::Repository.recognize_scm(File.join(TEST_ROOT, 'repositories', 'original')).should == 'git' | ||
end | ||
|
||
it "should recognize svn repositories" do | ||
Hail::Repository.recognize_scm(File.join(TEST_ROOT, 'repositories', 'clone')).should == 'svn' | ||
end | ||
|
||
it "should know that it doesn't recognize other repositories" do | ||
Hail::Repository.recognize_scm(File.join(TEST_ROOT, 'repositories')).should.be.nil | ||
end | ||
end | ||
|
||
describe "A Git Repository" do | ||
before do | ||
@repository = Hail::Repository.new(:directory => File.join(TEST_ROOT, 'repositories', 'original')) | ||
end | ||
|
||
it "should have 'git' as scm" do | ||
@repository.scm.should == 'git' | ||
end | ||
end | ||
|
||
describe "An Subversion Repository" do | ||
before do | ||
@repository = Hail::Repository.new(:directory => File.join(TEST_ROOT, 'repositories', 'clone')) | ||
end | ||
|
||
it "should have 'svn' as scm" do | ||
@repository.scm.should == 'svn' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
8 | ||
|
||
dir | ||
0 | ||
file:///Users/manfred/Code/hail/test/repositories/svn | ||
file:///Users/manfred/Code/hail/test/repositories/svn | ||
|
||
|
||
|
||
2008-08-20T16:49:35.624570Z | ||
0 | ||
|
||
|
||
|
||
svn:special svn:externals svn:needs-lock | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
c8febcad-ff5f-4c32-9116-c64acc132d67 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.git |