Repository#head throws exception, but documentation seems to imply it should return nil?

オープン
#754 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
git, ruby
領域
backend

調査の方向性

lib/relaxo/database.rb:48 と spec/relaxo/database_spec.rb の失敗している example から始め、その後、新しく作成された repository について、Rugged::Repository#head とリンク先の API ドキュメントを比較します。空の repository の動作が定義され、clear! の expectation が予期せず例外を発生させなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I have to do the following

		# Completely clear out the database.
		def clear!
			if head = @repository.head
				@repository.references.delete(head)
			end
		rescue Rugged::ReferenceError
			return nil
		end

@repository.head on a newly created repo throws:

 1) Relaxo::Database can clear database
     Failure/Error:
       expect do
       	database.clear!
       end.to_not raise_error
     
       expected no Exception, got #<Rugged::ReferenceError: reference 'refs/heads/master' not found> with backtrace:
         # ./lib/relaxo/database.rb:48:in `head'
         # ./lib/relaxo/database.rb:48:in `clear!'
         # ./spec/relaxo/database_spec.rb:20:in `block (3 levels) in <top (required)>'

The documentation seems to imply this should return nil?

https://www.rubydoc.info/github/libgit2/rugged/Rugged%2FRepository:head

Thanks!

主要言語
C
スター
2.3k
フォーク
293
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libgit2/rugged のほかの issue

libgit2/rugged の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。