Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use rugged to check if there are uncommited changes in my git repository?

How do I use rugged to check whether there are uncommitted changes in my git repo?

Much like How do I programmatically determine if there are uncommited changes?

like image 640
zlog Avatar asked Nov 04 '22 00:11

zlog


1 Answers

Wow. This question has been dead from some time, but thought I'd throw in my 2 cents as I'm using learning/using Rugged currently.

There's a handy method Repository#diff_workdir that exists nowadays.

Suppose you want to compare the working directory to the last commit( the equivalent of what I think of just a plain old git diff). You can get that with this:

repo.diff_workdir(repo.last_commit)

Hope this helps someone!

like image 122
James Milani Avatar answered Nov 15 '22 06:11

James Milani