8000 Repository · stettberger/metagit Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
stettberger edited this page Sep 23, 2010 · 5 revisions

The Repository objects

The Repository is the cental point of the metagit concept. It represents the connection of a remote Repository with a local clone, which might not exists at this very moment. It requires just one argument, the clone url, but normally you want to define several other keyword arguments (in this order):

  • local_url: The clone will be put exactly at this point, no matter what
  • into: if no local_url is defined, the clone will be put into this directory with the repository name appended (default: “~/”)
  • default_policy: See Policy section (default: “allow”)
  • scm: The scm used by this repository (default: Git())

Here some examples to illustrate the local_url/into stuff

Repository("user@remote:foobar.git", "~/barfoo") # The clone will be in ~/barfoo
Repository("user@remote:foobar.git", into = "~/") # The clone will be in ~/foobar (the .git is removed)

The Statusline

You will often have to see the statusline of a repository if you use metagit (everytime you list you repos with metagit list), so it would be useful if you have some understanding of it.

+ (git:hub) git@github.com:stettberger/metagit.git --> ~/github/metagit

First comes the state of the Repository on your local machine (here +), which says if your repo is existing (+), a bare repo (b), the local clone directory doesn’t exist (-) or it exists but isn’t a proper repository (N). After this the scm used by the repository is printed (here git) and after that the repository list (here hub). The rest is $clone_url –> $local_url.

Policy

The Policy of a repository is a set of rules on which machines a repository will be listed or ignored. This gives you the possibility to define all your repos, but see at on your local machine only the currently important ones. The policy defaults to allow, but can be changed in the Repository constuctor with the default_policy argument set to "deny". After this you can define several policies by the .add_policy() method of a Repository instance. Here must be a regex given that will be checked against the FQDN. Here a more complicated example:

Repository("remote.com:foobar", "~/barfoo", default_policy = "deny")\
 .add_policy("example.com", "allow")\
 .add_policy("foo.example.com", "deny")

This repo will just be listed add fqdns where \example.com\ will but \foo.example.com\ won’t match. You can use the exactly same mechanism with Repository Listers

SCM

Every Repository has an instance of a subclass of SCM, which defines the behaviour of a scm system. It defaults to Git(). At the moment there are several possibilities (with some predefined shortcuts for configuration)

  • git: Git(), git
  • mercurial: Mercurial(), hg, mercurial
  • git-svn: GitSvn(externals=False), gitsvn, git_svn, git_svn_externals, gitsvn_externals

    You can tweak your fresh SCM instances (NOT the shortcuts, this will explode), by adding some options to specify command. For example, if you want to add always to your pull command, use Git().add_option("pull", "--rebase") as your scm argument.

If you want to continue the metagit guided tour, goto Repository Listers, for defining a huge amount of repos at once.

Clone this wiki locally
0