| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e39c8b0 commit b9a2ea8
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,9 @@ install: | |||
| 25 | 25 | # as commits are performed with the default user, it needs to be set for travis too | |
| 26 | 26 | - git config --global user.email "travis@ci.com" | |
| 27 | 27 | - git config --global user.name "Travis Runner" | |
| 28 | + # If we rewrite the user's config by accident, we will mess it up | ||
| 29 | + # and cause subsequent tests to fail | ||
| 30 | + - cp git/test/fixtures/.gitconfig ~/ | ||
| 28 | 31 | script: | |
| 29 | 32 | # Make sure we limit open handles to see if we are leaking them | |
| 30 | 33 | - ulimit -n 96 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,6 +81,7 @@ def set_dirty_and_flush_changes(non_const_func): | |||
| 81 | 81 | ||
| 82 | 82 | def flush_changes(self, *args, **kwargs): | |
| 83 | 83 | rval = non_const_func(self, *args, **kwargs) | |
| 84 | + self._dirty = True | ||
| 84 | 85 | self.write() | |
| 85 | 86 | return rval | |
| 86 | 87 | # END wrapper method | |
@@ -190,6 +191,7 @@ def __init__(self, file_or_files, read_only=True, merge_includes=True): | |||
| 190 | 191 | ||
| 191 | 192 | self._file_or_files = file_or_files | |
| 192 | 193 | self._read_only = read_only | |
| 194 | + self._dirty = False | ||
| 193 | 195 | self._is_initialized = False | |
| 194 | 196 | self._merge_includes = merge_includes | |
| 195 | 197 | self._lock = None | |
@@ -304,7 +306,7 @@ def string_decode(v): | |||
| 304 | 306 | if mo: | |
| 305 | 307 | # We might just have handled the last line, which could contain a quotation we want to remove | |
| 306 | 308 | optname, vi, optval = mo.group('option', 'vi', 'value') | |
| 307 | - if vi in ('=', ':') and ';' in optval: | ||
| 309 | + if vi in ('=', ':') and ';' in optval and not optval.strip().startswith('"'): | ||
| 308 | 310 | pos = optval.find(';') | |
| 309 | 311 | if pos != -1 and optval[pos - 1].isspace(): | |
| 310 | 312 | optval = optval[:pos] | |
@@ -433,6 +435,8 @@ def write(self): | |||
| 433 | 435 | :raise IOError: if this is a read-only writer instance or if we could not obtain | |
| 434 | 436 | a file lock""" | |
| 435 | 437 | self._assure_writable("write") | |
| 438 | + if not self._dirty: | ||
| 439 | + return | ||
| 436 | 440 | ||
| 437 | 441 | if isinstance(self._file_or_files, (list, tuple)): | |
| 438 | 442 | raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + [alias] | ||
| 2 | + rbi = "!g() { git rebase -i origin/${1:-master} ; } ; g" | ||
| 3 | + expush = "!f() { git branch -f tmp ; { git rbi $1 && git push ; } ; git reset --hard tmp ; git rebase origin/${1:-master}; } ; f" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,6 @@ | |||
| 18 | 18 | ) | |
| 19 | 19 | import io | |
| 20 | 20 | import os | |
| 21 | - from copy import copy | ||
| 22 | 21 | from git.config import cp | |
| 23 | 22 | ||
| 24 | 23 | ||
@@ -30,21 +29,18 @@ def _to_memcache(self, file_path): | |||
| 30 | 29 | sio.name = file_path | |
| 31 | 30 | return sio | |
| 32 | 31 | ||
| 33 | - def _parsers_equal_or_raise(self, lhs, rhs): | ||
| 34 | - pass | ||
| 35 | - | ||
| 36 | 32 | def test_read_write(self): | |
| 37 | 33 | # writer must create the exact same file as the one read before | |
| 38 | 34 | for filename in ("git_config", "git_config_global"): | |
| 39 | 35 | file_obj = self._to_memcache(fixture_path(filename)) | |
| 40 | - file_obj_orig = copy(file_obj) | ||
| 41 | 36 | w_config = GitConfigParser(file_obj, read_only=False) | |
| 42 | 37 | w_config.read() # enforce reading | |
| 43 | 38 | assert w_config._sections | |
| 44 | 39 | w_config.write() # enforce writing | |
| 45 | 40 | ||
| 46 | 41 | # we stripped lines when reading, so the results differ | |
| 47 | - assert file_obj.getvalue() and file_obj.getvalue() != file_obj_orig.getvalue() | ||
| 42 | + assert file_obj.getvalue() | ||
| 43 | + self.assertEqual(file_obj.getvalue(), self._to_memcache(fixture_path(filename)).getvalue()) | ||
| 48 | 44 | ||
| 49 | 45 | # creating an additional config writer must fail due to exclusive access | |
| 50 | 46 | self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only=False) | |
@@ -207,3 +203,10 @@ def test_rename(self): | |||
| 207 | 203 | assert not cw.has_section('core') | |
| 208 | 204 | assert len(cw.items(nn)) == 4 | |
| 209 | 205 | cw.release() | |
| 206 | + | ||
| 207 | + def test_complex_aliases(self): | ||
| 208 | + file_obj = self._to_memcache(fixture_path('.gitconfig')) | ||
| 209 | + w_config = GitConfigParser(file_obj, read_only=False) | ||
| 210 | + self.assertEqual(w_config.get('alias', 'rbi'), '"!g() { git rebase -i origin/${1:-master} ; } ; g"') | ||
| 211 | + w_config.release() | ||
| 212 | + self.assertEqual(file_obj.getvalue(), self._to_memcache(fixture_path('.gitconfig')).getvalue()) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments