Class Grit::Repo
In: lib/grit/repo.rb
Parent: Object

Methods

Constants

DAEMON_EXPORT_FILE = 'git-daemon-export-ok'

Attributes

bare  [R] 
git  [RW]  The git command line interface object
path  [RW]  The path of the git repo as a String
working_dir  [RW] 

Public Class methods

Initialize a bare git repository at the given path

  +path+ is the full path to the repo (traditionally ends with /<name>.git)
  +options+ is any additional options to the git init command

Examples

  Grit::Repo.init_bare('/var/git/myrepo.git')

Returns Grit::Repo (the newly created repo)

Create a new Repo instance

  +path+ is the path to either the root git directory or the bare git repo

Examples

  g = Repo.new("/Users/tom/dev/grit")
  g = Repo.new("/Users/tom/public/grit.git")

Returns Grit::Repo

Public Instance methods

Adds files to the index

The list of alternates for this repo

Returns Array[String] (pathnames of alternates)

Sets the alternates

  +alts+ is the Array of String paths representing the alternates

Returns nothing

Archive the given treeish

  +treeish+ is the treeish name/id (default 'master')
  +prefix+ is the optional prefix

Examples

  repo.archive_tar
  # => <String containing tar archive>

  repo.archive_tar('a87ff14')
  # => <String containing tar archive for commit a87ff14>

  repo.archive_tar('master', 'myproject/')
  # => <String containing tar archive and prefixed with 'myproject/'>

Returns String (containing tar archive)

Archive and gzip the given treeish

  +treeish+ is the treeish name/id (default 'master')
  +prefix+ is the optional prefix

Examples

  repo.archive_tar_gz
  # => <String containing tar.gz archive>

  repo.archive_tar_gz('a87ff14')
  # => <String containing tar.gz archive for commit a87ff14>

  repo.archive_tar_gz('master', 'myproject/')
  # => <String containing tar.gz archive and prefixed with 'myproject/'>

Returns String (containing tar.gz archive)

The Blob object for the given id

  +id+ is the SHA1 id of the blob

Returns Grit::Blob (unbaked)

branches()

Alias for heads

The Commit object for the specified id

  +id+ is the SHA1 identifier of the commit

Returns Grit::Commit (baked)

Commits all tracked and modified files

Returns true/false if commit worked

The number of commits reachable by the given branch/commit

  +start+ is the branch/commit name (default 'master')

Returns Integer

The commit diff for the given commit

  +commit+ is the commit name/id

Returns Grit::Diff[]

Commits current index

Returns true/false if commit worked

An array of Commit objects representing the history of a given ref/commit

  +start+ is the branch/commit name (default 'master')
  +max_count+ is the maximum number of commits to return (default 10, use +false+ for all)
  +skip+ is the number of commits to skip (default 0)

Returns Grit::Commit[] (baked)

The Commits objects that are reachable via to but not via from Commits are returned in chronological order.

  +from+ is the branch/commit name of the younger item
  +to+ is the branch/commit name of the older item

Returns Grit::Commit[] (baked)

The Commits objects that are newer than the specified date. Commits are returned in chronological order.

  +start+ is the branch/commit name (default 'master')
  +since+ is a string represeting a date/time
  +extra_options+ is a hash of extra options

Returns Grit::Commit[] (baked)

The project‘s description. Taken verbatim from GIT_REPO/description

Returns String

The diff from commit a to commit b, optionally restricted to the given file(s)

  +a+ is the base commit
  +b+ is the other commit
  +paths+ is an optional list of file paths on which to restrict the diff

Disable git-daemon serving of this repository by ensuring there is no git-daemon-export-ok file in its git directory

Returns nothing

Enable git-daemon serving of this repository by writing the git-daemon-export-ok file to its git directory

Returns nothing

Fork a bare git repository from this repo

  +path+ is the full path of the new repo (traditionally ends with /<name>.git)
  +options+ is any additional options to the git clone command

Returns Grit::Repo (the newly forked repo)

Object reprsenting the current repo head.

Returns Grit::Head (baked)

An array of Head objects representing the branch heads in this repo

Returns Grit::Head[] (baked)

Pretty object inspection

An array of Ref objects representing the refs in this repo

Returns Grit::Ref[] (baked)

An array of Remote objects representing the remote branches in this repo

Returns Grit::Remote[] (baked)

Adds files to the index

An array of Tag objects that are available in this repo

Returns Grit::Tag[] (baked)

The Tree object for the given treeish reference

  +treeish+ is the reference (default 'master')
  +paths+ is an optional Array of directory paths to restrict the tree (deafult [])

Examples

  repo.tree('master', ['lib/'])

Returns Grit::Tree (baked)

[Validate]