2014-10-15 6 views
0

Rugged :: Index #add를 사용하여 색인에 새 파일을 추가하려고합니다. 인덱스에 성공적으로 추가 된 것으로 보이지만 연관된 Rugged :: Repository #status 이 지정된 파일에 대해 지워집니다.Rugged :: Repository #status는 Rugged를 사용하여 색인에 파일을 추가 할 때 지워진 상태를보고합니다.

가 파일 "TEST_JJV_IRB1"를 추가 내 시도
>> path = "TEST_JJV_IRB1" 
=> "TEST_JJV_IRB1" 
>> FileUtils.touch("#{local_repo}/#{path}") 
=> ["/var/tmp/d20141015-95025-c5bbxe/TEST_JJV_IRB1"] 
>> repo.inspect 
=> "#<Rugged::Repository:70155837868280 {path: \"/private/var/tmp/d20141015-95025-c5bbxe/.git/\"}>" 

새로 생성 된 파일 "TEST_JJV_IRB1"을 보여주는

예 IRB 세션이 제대로 견고한 :: 저장소 #status에 의해보고

>> repo.status(path) 
=> [:worktree_new] 

및 올바르게 Rugged :: Index에 포함되지 않음

>> index = repo.index 
=> #<Rugged::Index 
    [0] 'a_file' 
    [0] 'b_file' 
    [0] 'c_file' 

여기에 새로운 파일을 색인에 추가하십시오.

>> oid = Rugged::Blob.from_workdir repo, path 
=> "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" 
>> index.add(:path => path, :oid => oid, :mode => 0100644) 
=> nil 
>> index.write 
=> nil 

파일 "TEST_JJV_IRB1"이 색인에 올바르게 추가되었습니다.

>> repo.index 
=> #<Rugged::Index 
    [0] 'a_file' 
    [0] 'b_file' 
    [0] 'c_file' 
    [0] 'TEST_JJV_IRB1' 

하지만 견고한 :: 저장소 #status보고 기대

>> repo.status(path) 
=> [] 

견고한 :: 저장소 #status 클리어로는 상태를보고 있어요 : 기묘 git status을 발행

[index_new]를 명령 줄에서 새 파일 "TEST_JJV_IRB1"을 "커밋 할 변경 내용 :"으로 표시합니다.

% git status 
On branch master 
Your branch is up-to-date with 'origin/master'. 

Changes to be committed: 
    (use "git reset HEAD <file>..." to unstage) 

    new file: TEST_JJV_IRB1 

+0

나는 매우 잘 Rugged :: Index #add를 잘못 사용했을 수도 있습니다 ...? –

답변

0

견고 함이 혼란 스럽습니다. addtype라는 제목의 두 번째 매개 변수가있는 것 같습니다 -

나는이 https://github.com/libgit2/rugged#writing-to-a-repository 보면 how can i use rugged to create and commit a file like from the command line?

유사하다 발견했다. 이 일이 바뀌 었습니까?

+0

답장을 보내 주셔서 감사합니다. 견고한 것은 혼란 스럽다! 비슷한 기사를 읽었습니다. http://stackoverflow.com/questions/24551308/how-can-i-use-rugged-to-create-and-commit-a-file-like-from-the-commandline repo.write에는 index.add가 아닌 param 유형이 있습니다. 내가 놓친 게 있니? –

+0

답장을 보내 주셔서 감사합니다. 견고한 것은 혼란 스럽다! 비슷한 기사를 읽었습니다. http://stackoverflow.com/questions/24551308/how-can-i-use-rugged-to-create-and-commit-a-file-like-from-the-commandline repo.write의 형식이 param이 아닌 index.add 인 것 같습니다. 또는 누락 되었습니까? repo.write 형식 매개 변수를 사용해 보았지만 영향을 미치지 않는 것으로 보입니다. –