OpenQuizz
Une application de gestion des contenus pédagogiques
Repo Class Reference
Inheritance diagram for Repo:
Collaboration diagram for Repo:

Public Member Functions

def __init__ (self, path=None, odbt=GitCmdObjectDB, search_parent_directories=False, expand_vars=True)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, traceback)
 
def __del__ (self)
 
def close (self)
 
def __eq__ (self, rhs)
 
def __ne__ (self, rhs)
 
def __hash__ (self)
 
def working_tree_dir (self)
 
def common_dir (self)
 
def bare (self)
 
def heads (self)
 
def references (self)
 
def index (self)
 
def head (self)
 
def remotes (self)
 
def remote (self, name='origin')
 
def submodules (self)
 
def submodule (self, name)
 
def create_submodule (self, *args, **kwargs)
 
def iter_submodules (self, *args, **kwargs)
 
def submodule_update (self, *args, **kwargs)
 
def tags (self)
 
def tag (self, path)
 
def create_head (self, path, commit='HEAD', force=False, logmsg=None)
 
def delete_head (self, *heads, **kwargs)
 
def create_tag (self, path, ref='HEAD', message=None, force=False, **kwargs)
 
def delete_tag (self, *tags)
 
def create_remote (self, name, url, **kwargs)
 
def delete_remote (self, remote)
 
def config_reader (self, config_level=None)
 
def config_writer (self, config_level="repository")
 
def commit (self, rev=None)
 
def iter_trees (self, *args, **kwargs)
 
def tree (self, rev=None)
 
def iter_commits (self, rev=None, paths='', **kwargs)
 
def merge_base (self, *rev, **kwargs)
 
def is_ancestor (self, ancestor_rev, rev)
 
def is_dirty (self, index=True, working_tree=True, untracked_files=False, submodules=True, path=None)
 
def untracked_files (self)
 
def ignored (self, *paths)
 
def active_branch (self)
 
def blame_incremental (self, rev, file, **kwargs)
 
def blame (self, rev, file, incremental=False, **kwargs)
 
def init (cls, path=None, mkdir=True, odbt=GitCmdObjectDB, expand_vars=True, **kwargs)
 
def clone (self, path, progress=None, multi_options=None, **kwargs)
 
def clone_from (cls, url, to_path, progress=None, env=None, multi_options=None, **kwargs)
 
def archive (self, ostream, treeish=None, prefix=None, **kwargs)
 
def has_separate_working_tree (self)
 
def __repr__ (self)
 
def currently_rebasing_on (self)
 

Data Fields

 odb
 

Static Public Attributes

 DAEMON_EXPORT_FILE
 
 git
 
 working_dir
 
 git_dir
 Walk up the path to find the .git dir. More...
 
 re_whitespace
 
 re_hexsha_only
 
 re_hexsha_shortened
 
 re_envvars
 
 re_author_committer_start
 
 re_tab_full_line
 
 config_level
 
 GitCommandWrapperType
 
 refs
 
 branches
 
 rev_parse
 

Properties

 description
 
 daemon_export
 
 alternates
 

Detailed Description

Represents a git repository and allows you to query references,
gather commit information, generate diffs, create and clone repositories query
the log.

The following attributes are worth using:

'working_dir' is the working directory of the git command, which is the working tree
directory if available or the .git directory in case of bare repositories

'working_tree_dir' is the working tree directory, but will raise AssertionError
if we are a bare repository.

'git_dir' is the .git repository directory, which is always set.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  path = None,
  odbt = GitCmdObjectDB,
  search_parent_directories = False,
  expand_vars = True 
)
Create a new Repo instance

:param path:
    the path to either the root git directory or the bare git repo::

repo = Repo("/Users/mtrier/Development/git-python")
repo = Repo("/Users/mtrier/Development/git-python.git")
repo = Repo("~/Development/git-python.git")
repo = Repo("$REPOSITORIES/Development/git-python.git")
repo = Repo("C:\\Users\\mtrier\\Development\\git-python\\.git")

    - In *Cygwin*, path may be a `'cygdrive/...'` prefixed path.
    - If it evaluates to false, :envvar:`GIT_DIR` is used, and if this also evals to false,
      the current-directory is used.
:param odbt:
    Object DataBase type - a type which is constructed by providing
    the directory containing the database objects, i.e. .git/objects. It will
    be used to access all object data
:param search_parent_directories:
    if True, all parent directories will be searched for a valid repo as well.

    Please note that this was the default behaviour in older versions of GitPython,
    which is considered a bug though.
:raise InvalidGitRepositoryError:
:raise NoSuchPathError:
:return: git.Repo 

◆ __del__()

def __del__ (   self)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __eq__()

def __eq__ (   self,
  rhs 
)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

◆ __hash__()

def __hash__ (   self)

◆ __ne__()

def __ne__ (   self,
  rhs 
)

◆ __repr__()

def __repr__ (   self)

◆ active_branch()

def active_branch (   self)
The name of the currently active branch.

:return: Head to the active branch

◆ archive()

def archive (   self,
  ostream,
  treeish = None,
  prefix = None,
**  kwargs 
)
Archive the tree at the given revision.

:param ostream: file compatible stream object to which the archive will be written as bytes
:param treeish: is the treeish name/id, defaults to active branch
:param prefix: is the optional prefix to prepend to each filename in the archive
:param kwargs: Additional arguments passed to git-archive

    * Use the 'format' argument to define the kind of format. Use
      specialized ostreams to write any format supported by python.
    * You may specify the special **path** keyword, which may either be a repository-relative
      path to a directory or file to place into the archive, or a list or tuple of multiple paths.

:raise GitCommandError: in case something went wrong
:return: self

◆ bare()

def bare (   self)
:return: True if the repository is bare

◆ blame()

def blame (   self,
  rev,
  file,
  incremental = False,
**  kwargs 
)
The blame information for the given file at the given revision.

:param rev: revision specifier, see git-rev-parse for viable options.
:return:
    list: [git.Commit, list: [<line>]]
    A list of tuples associating a Commit object with a list of lines that
    changed within the given commit. The Commit objects will be given in order
    of appearance.

◆ blame_incremental()

def blame_incremental (   self,
  rev,
  file,
**  kwargs 
)
Iterator for blame information for the given file at the given revision.

Unlike .blame(), this does not return the actual file's contents, only
a stream of BlameEntry tuples.

:param rev: revision specifier, see git-rev-parse for viable options.
:return: lazy iterator of BlameEntry tuples, where the commit
 indicates the commit to blame for the line, and range
 indicates a span of line numbers in the resulting file.

If you combine all line number ranges outputted by this command, you
should get a continuous range spanning all line numbers in the file.

◆ clone()

def clone (   self,
  path,
  progress = None,
  multi_options = None,
**  kwargs 
)
Create a clone from this repository.

:param path: is the full path of the new repo (traditionally ends with ./<name>.git).
:param progress: See 'git.remote.Remote.push'.
:param multi_options: A list of Clone options that can be provided multiple times.  One
    option per list item which is passed exactly as specified to clone.
    For example ['--config core.filemode=false', '--config core.ignorecase',
    '--recurse-submodule=repo1_path', '--recurse-submodule=repo2_path']
:param kwargs:
    * odbt = ObjectDatabase Type, allowing to determine the object database
      implementation used by the returned Repo instance
    * All remaining keyword arguments are given to the git-clone command

:return: ``git.Repo`` (the newly cloned repo)

◆ clone_from()

def clone_from (   cls,
  url,
  to_path,
  progress = None,
  env = None,
  multi_options = None,
**  kwargs 
)
Create a clone from the given URL

:param url: valid git url, see http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS
:param to_path: Path to which the repository should be cloned to
:param progress: See 'git.remote.Remote.push'.
:param env: Optional dictionary containing the desired environment variables.
    Note: Provided variables will be used to update the execution
    environment for `git`. If some variable is not specified in `env`
    and is defined in `os.environ`, value from `os.environ` will be used.
    If you want to unset some variable, consider providing empty string
    as its value.
:param multi_options: See ``clone`` method
:param kwargs: see the ``clone`` method
:return: Repo instance pointing to the cloned directory

◆ close()

def close (   self)

◆ commit()

def commit (   self,
  rev = None 
)
The Commit object for the specified revision

:param rev: revision specifier, see git-rev-parse for viable options.
:return: ``git.Commit``

◆ common_dir()

def common_dir (   self)
:return: The git dir that holds everything except possibly HEAD,
    FETCH_HEAD, ORIG_HEAD, COMMIT_EDITMSG, index, and logs/.

◆ config_reader()

def config_reader (   self,
  config_level = None 
)
:return:
    GitConfigParser allowing to read the full git configuration, but not to write it

    The configuration will include values from the system, user and repository
    configuration files.

:param config_level:
    For possible values, see config_writer method
    If None, all applicable levels will be used. Specify a level in case
    you know which file you wish to read to prevent reading multiple files.
:note: On windows, system configuration cannot currently be read as the path is
    unknown, instead the global path will be used.

◆ config_writer()

def config_writer (   self,
  config_level = "repository" 
)
:return:
    GitConfigParser allowing to write values of the specified configuration file level.
    Config writers should be retrieved, used to change the configuration, and written
    right away as they will lock the configuration file in question and prevent other's
    to write it.

:param config_level:
    One of the following values
    system = system wide configuration file
    global = user level configuration file
    repository = configuration file for this repository only

◆ create_head()

def create_head (   self,
  path,
  commit = 'HEAD',
  force = False,
  logmsg = None 
)
Create a new head within the repository.
For more documentation, please see the Head.create method.

:return: newly created Head Reference

◆ create_remote()

def create_remote (   self,
  name,
  url,
**  kwargs 
)
Create a new remote.

For more information, please see the documentation of the Remote.create
methods

:return: Remote reference

◆ create_submodule()

def create_submodule (   self,
args,
**  kwargs 
)
Create a new submodule

:note: See the documentation of Submodule.add for a description of the
    applicable parameters
:return: created submodules

◆ create_tag()

def create_tag (   self,
  path,
  ref = 'HEAD',
  message = None,
  force = False,
**  kwargs 
)
Create a new tag reference.
For more documentation, please see the TagReference.create method.

:return: TagReference object 

◆ currently_rebasing_on()

def currently_rebasing_on (   self)
:return: The commit which is currently being replayed while rebasing.

None if we are not currently rebasing.

◆ delete_head()

def delete_head (   self,
heads,
**  kwargs 
)
Delete the given heads

:param kwargs: Additional keyword arguments to be passed to git-branch

◆ delete_remote()

def delete_remote (   self,
  remote 
)
Delete the given remote.

◆ delete_tag()

def delete_tag (   self,
tags 
)
Delete the given tag references

◆ has_separate_working_tree()

def has_separate_working_tree (   self)
:return: True if our git_dir is not at the root of our working_tree_dir, but a .git file with a
    platform agnositic symbolic link. Our git_dir will be wherever the .git file points to
:note: bare repositories will always return False here

◆ head()

def head (   self)
:return: HEAD Object pointing to the current head reference

◆ heads()

def heads (   self)
A list of ``Head`` objects representing the branch heads in
this repo

:return: ``git.IterableList(Head, ...)``

◆ ignored()

def ignored (   self,
paths 
)
Checks if paths are ignored via .gitignore
Doing so using the "git check-ignore" method.

:param paths: List of paths to check whether they are ignored or not
:return: subset of those paths which are ignored

◆ index()

def index (   self)
:return: IndexFile representing this repository's index.
:note: This property can be expensive, as the returned ``IndexFile`` will be
 reinitialized. It's recommended to re-use the object.

◆ init()

def init (   cls,
  path = None,
  mkdir = True,
  odbt = GitCmdObjectDB,
  expand_vars = True,
**  kwargs 
)
Initialize a git repository at the given path if specified

:param path:
    is the full path to the repo (traditionally ends with /<name>.git)
    or None in which case the repository will be created in the current
    working directory

:param mkdir:
    if specified will create the repository directory if it doesn't
    already exists. Creates the directory with a mode=0755.
    Only effective if a path is explicitly given

:param odbt:
    Object DataBase type - a type which is constructed by providing
    the directory containing the database objects, i.e. .git/objects.
    It will be used to access all object data

:param expand_vars:
    if specified, environment variables will not be escaped. This
    can lead to information disclosure, allowing attackers to
    access the contents of environment variables

:param kwargs:
    keyword arguments serving as additional options to the git-init command

:return: ``git.Repo`` (the newly created repo)

◆ is_ancestor()

def is_ancestor (   self,
  ancestor_rev,
  rev 
)
Check if a commit is an ancestor of another

:param ancestor_rev: Rev which should be an ancestor
:param rev: Rev to test against ancestor_rev
:return: ``True``, ancestor_rev is an ancestor to rev.

◆ is_dirty()

def is_dirty (   self,
  index = True,
  working_tree = True,
  untracked_files = False,
  submodules = True,
  path = None 
)
:return:
    ``True``, the repository is considered dirty. By default it will react
    like a git-status without untracked files, hence it is dirty if the
    index or the working copy have changes.

◆ iter_commits()

def iter_commits (   self,
  rev = None,
  paths = '',
**  kwargs 
)
A list of Commit objects representing the history of a given ref/commit

:param rev:
    revision specifier, see git-rev-parse for viable options.
    If None, the active branch will be used.

:param paths:
    is an optional path or a list of paths to limit the returned commits to
    Commits that do not contain that path or the paths will not be returned.

:param kwargs:
    Arguments to be passed to git-rev-list - common ones are
    max_count and skip

:note: to receive only commits between two named revisions, use the
    "revA...revB" revision specifier

:return: ``git.Commit[]``

◆ iter_submodules()

def iter_submodules (   self,
args,
**  kwargs 
)
An iterator yielding Submodule instances, see Traversable interface
for a description of args and kwargs
:return: Iterator

◆ iter_trees()

def iter_trees (   self,
args,
**  kwargs 
)
:return: Iterator yielding Tree objects
:note: Takes all arguments known to iter_commits method

◆ merge_base()

def merge_base (   self,
rev,
**  kwargs 
)
Find the closest common ancestor for the given revision (e.g. Commits, Tags, References, etc)

:param rev: At least two revs to find the common ancestor for.
:param kwargs: Additional arguments to be passed to the repo.git.merge_base() command which does all the work.
:return: A list of Commit objects. If --all was not specified as kwarg, the list will have at max one Commit,
    or is empty if no common merge base exists.
:raises ValueError: If not at least two revs are provided

◆ references()

def references (   self)
A list of Reference objects representing tags, heads and remote references.

:return: IterableList(Reference, ...)

◆ remote()

def remote (   self,
  name = 'origin' 
)
:return: Remote with the specified name
:raise ValueError:  if no remote with such a name exists

◆ remotes()

def remotes (   self)
A list of Remote objects allowing to access and manipulate remotes
:return: ``git.IterableList(Remote, ...)``

◆ submodule()

def submodule (   self,
  name 
)
:return: Submodule with the given name
:raise ValueError: If no such submodule exists

◆ submodule_update()

def submodule_update (   self,
args,
**  kwargs 
)
Update the submodules, keeping the repository consistent as it will
take the previous state into consideration. For more information, please
see the documentation of RootModule.update

◆ submodules()

def submodules (   self)
:return: git.IterableList(Submodule, ...) of direct submodules
    available from the current head

◆ tag()

def tag (   self,
  path 
)
:return: TagReference Object, reference pointing to a Commit or Tag
:param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 

◆ tags()

def tags (   self)
A list of ``Tag`` objects that are available in this repo
:return: ``git.IterableList(TagReference, ...)`` 

◆ tree()

def tree (   self,
  rev = None 
)
The Tree object for the given treeish revision
Examples::

      repo.tree(repo.heads[0])

:param rev: is a revision pointing to a Treeish ( being a commit or tree )
:return: ``git.Tree``

:note:
    If you need a non-root level tree, find it by iterating the root tree. Otherwise
    it cannot know about its path relative to the repository root and subsequent
    operations might have unexpected results.

◆ untracked_files()

def untracked_files (   self)
:return:
    list(str,...)

    Files currently untracked as they have not been staged yet. Paths
    are relative to the current working directory of the git command.

:note:
    ignored files will not appear here, i.e. files mentioned in .gitignore
:note:
    This property is expensive, as no cache is involved. To process the result, please
    consider caching it yourself.

◆ working_tree_dir()

def working_tree_dir (   self)
:return: The working tree directory of our git repository. If this is a bare repository, None is returned.

Field Documentation

◆ branches

branches
static

◆ config_level

config_level
static

◆ DAEMON_EXPORT_FILE

DAEMON_EXPORT_FILE
static

◆ git

git
static

◆ git_dir

git_dir
static

Walk up the path to find the .git dir.

◆ GitCommandWrapperType

GitCommandWrapperType
static

◆ odb

odb

◆ re_author_committer_start

re_author_committer_start
static

◆ re_envvars

re_envvars
static

◆ re_hexsha_only

re_hexsha_only
static

◆ re_hexsha_shortened

re_hexsha_shortened
static

◆ re_tab_full_line

re_tab_full_line
static

◆ re_whitespace

re_whitespace
static

◆ refs

refs
static

◆ rev_parse

rev_parse
static

◆ working_dir

working_dir
static

Property Documentation

◆ alternates

alternates
static
Initial value:
= property(_get_alternates, _set_alternates,
doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")

◆ daemon_export

daemon_export
static
Initial value:
= property(_get_daemon_export, _set_daemon_export,
doc="If True, git-daemon may export this repository")

◆ description

description
static
Initial value:
= property(_get_description, _set_description,
doc="the project's description")

The documentation for this class was generated from the following file: