diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-21 11:45:32 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-21 11:45:32 +0100 |
commit | e48e52001d5abad7b28a4ecadde63c78c3946339 (patch) | |
tree | 2f3a3b274f7e4d782bfd9ebbbbd42f2d71e2830b /git | |
parent | c3c6c81b3281333a5a1152f667c187c9dce12944 (diff) | |
download | gitpython-e48e52001d5abad7b28a4ecadde63c78c3946339.tar.gz |
Initial set of documentation improvements, and a fix to the submodule tests.
Now travisci tests should work once again.
Related to #239
Diffstat (limited to 'git')
-rw-r--r-- | git/cmd.py | 2 | ||||
-rw-r--r-- | git/objects/base.py | 7 | ||||
-rw-r--r-- | git/test/test_docs.py | 49 | ||||
-rw-r--r-- | git/test/test_submodule.py | 2 |
4 files changed, 52 insertions, 8 deletions
@@ -295,7 +295,7 @@ class Git(LazyMixin): :raise GitCommandError: if the return status is not 0""" status = self.proc.wait() if status != 0: - raise GitCommandError(self.args, status, self.proc.stderr.read().decode(defenc)) + raise GitCommandError(self.args, status, self.proc.stderr.read()) # END status handling return status # END auto interrupt diff --git a/git/objects/base.py b/git/objects/base.py index eb59b0a9..42876fc8 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -132,9 +132,11 @@ class IndexObject(Object): def __init__(self, repo, binsha, mode=None, path=None): """Initialize a newly instanced IndexObject + :param repo: is the Repo we are located in :param binsha: 20 byte sha1 - :param mode: is the stat compatible file mode as int, use the stat module + :param mode: + is the stat compatible file mode as int, use the stat module to evaluate the infomration :param path: is the path to the file in the file system, relative to the git repository root, i.e. @@ -149,7 +151,8 @@ class IndexObject(Object): self.path = path def __hash__(self): - """:return: + """ + :return: Hash of our path as index items are uniquely identifyable by path, not by their data !""" return hash(self.path) diff --git a/git/test/test_docs.py b/git/test/test_docs.py index 5ebae513..6befb9ea 100644 --- a/git/test/test_docs.py +++ b/git/test/test_docs.py @@ -6,21 +6,62 @@ # 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): +class Tutorials(TestBase): + + @with_rw_directory + def test_init_repo_object(self, rw_dir): + from git import Repo + join = os.path.join + + # rorepo is a a Repo instance pointing to the git-python repository. + # For all you know, the first argument to Repo is a path to the repository + # you want to work with + repo = Repo(self.rorepo.working_tree_dir) + assert repo.bare == False + # ![1-test_init_repo_object] + + # [2-test_init_repo_object] + bare_empty_repo = Repo.init(join(rw_dir, 'bare-repo'), bare=True) + assert bare_empty_repo.bare == True + # ![2-test_init_repo_object] + + # [3-test_init_repo_object] + repo.config_reader() # get a config reader for read-only access + cw = repo.config_writer() # get a config writer to change configuration + cw.release() # call release() to be sure changes are written and locks are released + # ![3-test_init_repo_object] + + # [4-test_init_repo_object] + repo.is_dirty() + # False + repo.untracked_files + # ['my_untracked_file'] + # ![4-test_init_repo_object] + + # [5-test_init_repo_object] + assert repo.clone(join(rw_dir, 'to/this/path')).__class__ is Repo + assert Repo.init(join(rw_dir, 'path/for/new/repo')).__class__ is Repo + # ![5-test_init_repo_object] + + # [6-test_init_repo_object] + repo.archive(open(join(rw_dir, 'repo.tar'), 'w')) + # ![6-test_init_repo_object] @with_rw_directory def test_add_file_and_commit(self, rw_dir): + import git + 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) + open(file_name, 'wb').close() r.index.add([file_name]) r.index.commit("initial commit") + + # ![test_add_file_and_commit] diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 49ab2586..1d4cf178 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -783,7 +783,7 @@ class TestSubmodule(TestBase): # Setup initial sandbox: # parent repo has one submodule, which has all the latest changes source_url = self._submodule_url() - sm_source_repo = git.Repo.clone_from(source_url, os.path.join(rw_dir, 'sm-source')) + sm_source_repo = git.Repo.clone_from(source_url, os.path.join(rw_dir, 'sm-source'), b='master') parent_repo = git.Repo.init(os.path.join(rw_dir, 'parent')) sm = parent_repo.create_submodule('mysubmodule', 'subdir/submodule', sm_source_repo.working_tree_dir, branch='master') |