2011-02-17 2 views

답변

0

나는이 함께 올라오고 결국 :

실행이 역 따옴표 표현입니다
# Check if a Branch Exists 
def branch_exists(branch) 
    branches = run("git branch",false) 
    regex = Regexp.new('[\\n\\s\\*]+' + Regexp.escape(branch.to_s) + '\\n') 
    result = ((branches =~ regex) ? true : false) 
    return result 
end 

. 그 이유는 코드가 이식성이 뛰어나고 다른 종속성을 허용하지 않기 때문입니다. git는 환경에 설치되는 반면.

5

자식 저장소에 액세스하기위한 루비 라이브러리가 있으며, 하나는 grit입니다.

[sudo] gem install grit을 설치하려면 설치하십시오.

$ irb 
>> require 'grit' 
=> true 
>> repo = Grit::Repo.new('/path/to/your/repo/') 
=> #<Grit::Repo "/path/to/your/repo/.git"> 
>> repo.branches 
=> [#<Grit::Head "master">, #<Grit::Head "some-topic-branch">, ...] 
관련 문제