From e395ac90bf088ad6b5de7dadb6531a6e7f3f4f3f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 19 Jan 2015 18:53:40 +0100 Subject: Added tutorial about initializing a repository. Additionally, for this and future examples, there is a test_doc.py suite to contain all code mentioned in the docs. That way, we know if things stop working. Fixes #236 --- git/test/test_docs.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 git/test/test_docs.py (limited to 'git/test/test_docs.py') diff --git a/git/test/test_docs.py b/git/test/test_docs.py new file mode 100644 index 00000000..5ebae513 --- /dev/null +++ b/git/test/test_docs.py @@ -0,0 +1,26 @@ +#-*-coding:utf-8-*- +# test_git.py +# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors +# +# This module is part of GitPython and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php +import os + +import git +from git.test.lib import TestBase +from gitdb.test.lib import with_rw_directory +from git.repo.fun import touch + + +class TestGit(TestBase): + + @with_rw_directory + def test_add_file_and_commit(self, rw_dir): + repo_dir = os.path.join(rw_dir, 'my-new-repo') + file_name = os.path.join(repo_dir, 'new-file') + + r = git.Repo.init(repo_dir) + # This function just creates an empty file ... + touch(file_name) + r.index.add([file_name]) + r.index.commit("initial commit") -- cgit v1.2.1