Questions tagged [grit]

A rubygem that allows OO access to git repositories.

grit in it's own words:

Grit gives you object oriented read/write access to Git repositories via Ruby. The main goals are stability and performance. To this end, some of the interactions with Git repositories are done by shelling out to the system's git command, and other interactions are done with pure Ruby reimplementations of core Git functionality. This choice, however, is transparent to end users, and you need not know which method is being used.

Certain parts of grit rely on the git binary, others are implemented in pure ruby. The distinction between the two is contained here.

35 questions
1
vote
3 answers

How to display commit content in ruby

How do you display the commit content specified with SHA-1 in a Ruby on Rails application?
Kazimír
  • 31
  • 2
1
vote
1 answer

Create a repo using Grit

Is there a way to create a branch in a repo using Grit? I can't seem to find a way in the docs nor is there any reference I can find on the web.
Ilya Sterin
  • 697
  • 1
  • 5
  • 6
1
vote
2 answers

Grit remove file in commit

I using Grit/Git as a database to track files added to a blog. I can't find any example of how I would delete a file from the index. I still want to be able to have the file in my Git history (being able to get it by going back in commit history),…
Ronze
  • 1,544
  • 2
  • 18
  • 33
1
vote
0 answers

Grit: Find blob by ID

Is there any way that I can get a blob by id using Grit? I know I can do this: @repo.tree/"myfile.txt" But is there any way I can get a blob from the tree by its id? EDIT: Solution was this: https://github.com/mojombo/grit/issues/#issue/12
Ronze
  • 1,544
  • 2
  • 18
  • 33
1
vote
2 answers

In ruby/grit, how do I get a list of files changed in a specific commit?

I want a list of files affected by a certain commit in git. Through the command line, I can do this with: git show --pretty="format:" --name-only (sha) But how can I do this through Grit in Ruby?
tim
  • 43
  • 4
1
vote
1 answer

Grit commit seems to be overriding last commit in Git repo?

I'm using Grit to create a repo and committing as few times. Every time I commit, my commit is saved, but the old one disappears. Anyone have any clue what I'm doing wrong? First I create a repo and make a commit. If I log the commit, I get the…
Ronze
  • 1,544
  • 2
  • 18
  • 33
1
vote
1 answer

get latest commit for blob with ruby/grit

i cloned a copy of the git-wiki for some educational programming. now, as a challange, i tried to figure out how to get the date for the blob. the blob is fetched with repository.tree/(page_name + extension) as far as i saw it, you can only get a…
mheck
  • 11
  • 1
1
vote
1 answer

git + grit working directory revision information

I'm trying to display some git version information (via grit) in my rails application footer for debuging. When I want to see the head, it's straightforward: @git_repository = Grit::Repo.new( Ter::Application.root ) head =…
galileoMonkey
  • 715
  • 6
  • 12
1
vote
2 answers

grit - trying to add files to git repo with out writing them to the file system

mkdir /tmp/scratch cd /tmp/scratch git init . --*-- xx.rb: SCRATCH = '/tmp/scratch' repo = Repo.new(SCRATCH) def add_multiple_commits_same_file_different_content(repo) previous_commit = repo.commits.first && repo.commits.first.id dir = "./" …
0
votes
1 answer

Grit commit_diff shows reverse diff

I'm trying to do a very simple thing: Read a diff from a git repo via the ruby gem Grit. I'm creating a file and adding the line "This is me changing the first file". Now I do this to get the diff: r = Grit::Repo.new("myrepo") c = r.commits.first d…
Ronze
  • 1,544
  • 2
  • 18
  • 33
0
votes
1 answer

Using grit with Ruby on rails

When I use rails c, I could type repo = Grit::Repo.name("/path/path") and there is no error. But when I type these in my rails controller, there is a error message showing: uninitialized constant AaaController::Grit , and if I add require 'grit' ,…
Jett Hsieh
  • 3,159
  • 27
  • 33
0
votes
1 answer

How to find blob in tree by its name

I have a tree of commit found by SHA-1,code is: tree = repo.tree(sha) now I need to find blob by file name and display its content
Kazimír
  • 31
  • 2
0
votes
1 answer

Grit submodule update returns nil

Working on a ruby/git project using Grit, but I'm unable to update my submodules programmatically. I figured out how the missing_method function maps to git and how to use it to perform tasks not written in to grit, however the submodule update…
Z99
  • 73
  • 7
0
votes
1 answer

Grit: Show all files in master

I'm trying to wrap my head around using Grit to write to a Git repository. I can easily create a repo and make a commit: repo = Repo.init_bare("grit.git") index = Index.new(repo) index.add('myfile.txt', 'This is the content') index.commit('first…
Ronze
  • 1,544
  • 2
  • 18
  • 33
0
votes
1 answer

How do you find out what files where changed between commits using Grit

I am having trouble trying to find out what files changed between two different commits. Here is the setup, version of Ruby and the Gem Grit, and what happens when I run the program: > cd /temp > mkdir tt > cd tt > git init Initialized empty Git…
John Goodson
  • 191
  • 1
  • 1
  • 3