2
0

porcelain.txt 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. Porcelain
  2. =========
  3. The ``porcelain`` is the higher level interface, built on top of the lower
  4. level implementation covered in previous chapters of this tutorial. The
  5. ``dulwich.porcelain`` module in Dulwich is aimed to closely resemble
  6. the Git command-line API that you are familiar with.
  7. Basic concepts
  8. --------------
  9. The porcelain operations are implemented as top-level functions in the
  10. ``dulwich.porcelain`` module. Most arguments can either be strings or
  11. more complex Dulwich objects; e.g. a repository argument will either take
  12. a string with a path to the repository or an instance of a ``Repo`` object.
  13. Initializing a new repository
  14. -----------------------------
  15. >>> from dulwich import porcelain
  16. >>> repo = porcelain.init("myrepo")
  17. Clone a repository
  18. ------------------
  19. >>> porcelain.clone("git://github.com/jelmer/dulwich", "dulwich-clone")
  20. Commit changes
  21. --------------
  22. >>> r = porcelain.init("testrepo")
  23. >>> open("testrepo/testfile", "w").write("data")
  24. >>> porcelain.add(r, "testfile")
  25. >>> porcelain.commit(r, b"A sample commit")