libgit2 / libgit2/rugged

Rugged::Tree#path throws exception when path doesn't exist

Open
#683 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

Rugged::Tree#path throws an exception if the path doesn't exist. But this can often be normal control flow.

> @tree.path("foo/bar")
Rugged::TreeError: the path 'foo' does not exist in the given tree

There are definitely exceptional cases - e.g. corruption of the git repository.

Solution:

  • Mark this method as deprecated.
  • Introduce new method fetch(path, default=nil, &block) which works similar to Hash#fetch.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Rugged::Tree#path entry point and trace how a missing path is currently handled. Define the proposed fetch(path, default=nil, &block) behavior against the issue's Hash#fetch comparison, while preserving exceptional repository errors; done means path is deprecated and fetch covers the requested missing-path cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, ruby
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.