libgit2 / libgit2/rugged

Repository#status is hard to use.

Open
#701 3 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

Here is an example:

changes = {}
repository.status do |file, status|
	unless status == [:ignored]
		changes[file] = status
	end
end

next if changes.empty?

logger.info "Package #{package.name} (from #{package.path}):".bright

changes.each do |file, status|
	if status == [:worktree_new]
		logger.info "\t#{file}".color(:blue)
	elsif status == [:worktree_modified]
		logger.info "\t#{file}".color(:orange)
	elsif status == [:worktree_deleted]
		logger.info "\t#{file}".color(:red)
	else
		logger.info "\t#{file} #{status.inspect}"
	end
end

I firstly have to assemble the list of changes into a hash, then check if it's empty, before finally printing out details.

It would be nice if you could write changes = repository.status or even better, if repository.status could return a chainable enumerable to_enum.

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 by reading the Repository#status API and the example in the issue to understand its current callback behavior. Decide whether the completed behavior should support direct changes = repository.status, a chainable enumerable, or both; done means callers can inspect status results without first assembling a hash.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, ruby
Domain
api, developer-experience
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.