| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ CHANGES | |||
| 6 | 6 | ===== | |
| 7 | 7 | Corrected problem with Tree.__div__ not working with zero length files. | |
| 8 | 8 | Removed __len__ override and replaced with size instead. Also made size cache | |
| 9 | - properly. | ||
| 9 | + properly. This is a breaking change. | ||
| 10 | 10 | ||
| 11 | 11 | 0.1.1 | |
| 12 | 12 | ===== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - Copyright (c) 2008, Michael Trier | ||
| 1 | + Copyright (c) 2008, Michael Trier and contributors | ||
| 2 | 2 | All rights reserved. | |
| 3 | 3 | ||
| 4 | 4 | Redistribution and use in source and binary forms, with or without | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,7 @@ In the above example, the directory ``/Users/mtrier/Development/git-python`` | |||
| 59 | 59 | is my working repository and contains the ``.git`` directory. You can also | |
| 60 | 60 | initialize GitPython with a bare repository. | |
| 61 | 61 | ||
| 62 | - >>> repo = Repo.init_bare("/var/git/git-python.git") | ||
| 62 | + >>> repo = Repo.create("/var/git/git-python.git") | ||
| 63 | 63 | ||
| 64 | 64 | Getting a list of commits | |
| 65 | 65 | ************************* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1 @@ | |||
| 1 | - 0.1.1 | ||
| 1 | + 0.1.2 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ def execute(self, command): | |||
| 26 | 26 | ``command`` | |
| 27 | 27 | The command to execute | |
| 28 | 28 | """ | |
| 29 | + print command | ||
| 29 | 30 | proc = subprocess.Popen(command, | |
| 30 | 31 | shell=True, | |
| 31 | 32 | stdout=subprocess.PIPE | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,13 +250,17 @@ def commit_diff(self, commit): | |||
| 250 | 250 | return Commit.diff(self, commit) | |
| 251 | 251 | ||
| 252 | 252 | @classmethod | |
| 253 | - def init_bare(self, path, **kwargs): | ||
| 253 | + def init_bare(self, path, mkdir=True, **kwargs): | ||
| 254 | 254 | """ | |
| 255 | 255 | Initialize a bare git repository at the given path | |
| 256 | 256 | ||
| 257 | 257 | ``path`` | |
| 258 | 258 | is the full path to the repo (traditionally ends with /<name>.git) | |
| 259 | 259 | ||
| 260 | + ``mkdir`` | ||
| 261 | + if specified will create the repository directory if it doesn't | ||
| 262 | + already exists. Creates the directory with a mode=0755. | ||
| 263 | + | ||
| 260 | 264 | ``kwargs`` | |
| 261 | 265 | is any additional options to the git init command | |
| 262 | 266 | ||
@@ -267,9 +271,19 @@ def init_bare(self, path, **kwargs): | |||
| 267 | 271 | Returns | |
| 268 | 272 | ``GitPython.Repo`` (the newly created repo) | |
| 269 | 273 | """ | |
| 270 | - git = Git(path) | ||
| 271 | - git.init(**kwargs) | ||
| 274 | + split = os.path.split(path) | ||
| 275 | + if split[-1] == '.git' or os.path.split(split[0])[-1] == '.git': | ||
| 276 | + gitpath = path | ||
| 277 | + else: | ||
| 278 | + gitpath = os.path.join(path, '.git') | ||
| 279 | + | ||
| 280 | + if mkdir and not os.path.exists(gitpath): | ||
| 281 | + os.makedirs(gitpath, 0755) | ||
| 282 | + | ||
| 283 | + git = Git(gitpath) | ||
| 284 | + output = git.init(**kwargs) | ||
| 272 | 285 | return Repo(path) | |
| 286 | + create = init_bare | ||
| 273 | 287 | ||
| 274 | 288 | def fork_bare(self, path, **kwargs): | |
| 275 | 289 | """ | |
@@ -284,7 +298,7 @@ def fork_bare(self, path, **kwargs): | |||
| 284 | 298 | Returns | |
| 285 | 299 | ``GitPython.Repo`` (the newly forked repo) | |
| 286 | 300 | """ | |
| 287 | - options = {'bare': True, 'shared': False} | ||
| 301 | + options = {'bare': True} | ||
| 288 | 302 | options.update(kwargs) | |
| 289 | 303 | self.git.clone(self.path, path, **options) | |
| 290 | 304 | return Repo(path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ def test_content_from_string_tree_should_return_commit(self): | |||
| 49 | 49 | def test_content_from_string_invalid_type_should_raise(self): | |
| 50 | 50 | self.tree.content_from_string(None, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test") | |
| 51 | 51 | ||
| 52 | - @patch(Blob, '__len__') | ||
| 52 | + @patch(Blob, 'size') | ||
| 53 | 53 | @patch(Git, 'method_missing') | |
| 54 | 54 | def test_slash(self, blob, git): | |
| 55 | 55 | git.return_value = fixture('ls_tree_a') | |
@@ -63,6 +63,20 @@ def test_slash(self, blob, git): | |||
| 63 | 63 | assert_true(git.called) | |
| 64 | 64 | assert_equal(git.call_args, (('ls_tree', 'master'), {})) | |
| 65 | 65 | ||
| 66 | + @patch(Blob, 'size') | ||
| 67 | + @patch(Git, 'method_missing') | ||
| 68 | + def test_slash_with_zero_length_file(self, blob, git): | ||
| 69 | + git.return_value = fixture('ls_tree_a') | ||
| 70 | + blob.return_value = 0 | ||
| 71 | + | ||
| 72 | + tree = self.repo.tree('master') | ||
| 73 | + | ||
| 74 | + assert_not_none(tree/'README.txt') | ||
| 75 | + assert_equal('8b1e02c0fb554eed2ce2ef737a68bb369d7527df', (tree/'README.txt').id) | ||
| 76 | + | ||
| 77 | + assert_true(git.called) | ||
| 78 | + assert_equal(git.call_args, (('ls_tree', 'master'), {})) | ||
| 79 | + | ||
| 66 | 80 | @patch(Git, 'method_missing') | |
| 67 | 81 | def test_slash_with_commits(self, git): | |
| 68 | 82 | git.return_value = fixture('ls_tree_commit') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments