File: porcelain.txt

package info (click to toggle)
dulwich 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,388 kB
  • sloc: python: 99,991; makefile: 163; sh: 67
file content (47 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Porcelain
=========

The ``porcelain`` is the higher level interface, built on top of the lower
level implementation covered in previous chapters of this tutorial. The
``dulwich.porcelain`` module in Dulwich is aimed to closely resemble
the Git command-line API that you are familiar with.

Basic concepts
--------------
The porcelain operations are implemented as top-level functions in the
``dulwich.porcelain`` module. Most arguments can either be strings or
more complex Dulwich objects; e.g. a repository argument will either take
a string with a path to the repository or an instance of a ``Repo`` object.

Initializing a new repository
-----------------------------

  >>> from dulwich import porcelain

  >>> repo = porcelain.init("myrepo")

Clone a repository
------------------

  >>> porcelain.clone("git://github.com/jelmer/dulwich", "dulwich-clone")
  
Basic authentication works using the ``username`` and ``password`` parameters:

  >>> porcelain.clone(
      "https://example.com/a-private-repo.git",
      "a-private-repo-clone",
      username="user", password="password")

Commit changes
--------------

  >>> r = porcelain.init("testrepo")
  >>> open("testrepo/testfile", "w").write("data")
  >>> porcelain.add(r, "testfile")
  >>> porcelain.commit(r, b"A sample commit")

Push changes
------------

  >>> tr = porcelain.init("targetrepo")
  >>> r = porcelain.push("testrepo", "targetrepo", "master")