Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simplify getting dirty files in repository#2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
clyvari wants to merge2 commits intolibgit2:master
base:master
Choose a base branch
Loading
fromclyvari:feat/is-dirty-detection-for-status-entry

Conversation

@clyvari
Copy link

A simple PR to help getting the dirty files in the repository.

Background: When getting aRepositoryStatus, we can use theIsDirty property to tell if the repository is dirty.
However, we don't have the same convenience to get the list of those dirty files.

Indeed, getting the actual list of dirty files would imply some duplicated logic in the client code, the same code that is present in theRepositoryStatus ctor to initialize theIsDirty prop.

What I propose is two parts (and 2 independent commits):

  1. Most importantly, we move theIsDirty detection inside a StatusEntry, by adding a property of the same name. Before, the detection was done inside theRepositoryStatus ctor, analyzing each StatusEntryFileStatus. Now each StatusEntry has the responsibility of telling whether it is dirty.

  2. Least importantly, but I think it's nice, we add aDirty collection insideRepositoryStatus, that is initialized with all theIsDirty StatusEntries

Before thos changes, a client code working with dirty files could look like this:

if(repositoryStatus.IsDirty){vardirtyFiles=repositoryStatus.Where(file=>file.State!=FileStatus.Ignored&&file.State!=FileStatus.Unaltered)// Duplicated Logic}

With those two modifications, the client code would look like this:

if(repositoryStatus.IsDirty){vardirtyFiles=repositoryStatus.Dirty;}

I appreciate any feedback, let me know if anything need to be changed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@clyvari

[8]ページ先頭

©2009-2025 Movatter.jp