| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,19 +68,15 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init= | |||
| 68 | 68 | ################## | |
| 69 | 69 | cur_commit = repo.head.commit | |
| 70 | 70 | if previous_commit is None: | |
| 71 | - symref = repo.head.orig_head() | ||
| 72 | 71 | try: | |
| 73 | - previous_commit = symref.commit | ||
| 74 | - except Exception: | ||
| 75 | - pcommits = cur_commit.parents | ||
| 76 | - if pcommits: | ||
| 77 | - previous_commit = pcommits[0] | ||
| 78 | - else: | ||
| 79 | - # in this special case, we just diff against ourselve, which | ||
| 80 | - # means exactly no change | ||
| 81 | - previous_commit = cur_commit | ||
| 82 | - # END handle initial commit | ||
| 83 | - # END no ORIG_HEAD | ||
| 72 | + previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha) | ||
| 73 | + if previous_commit.binsha == previous_commit.NULL_BIN_SHA: | ||
| 74 | + raise IndexError | ||
| 75 | + #END handle initial commit | ||
| 76 | + except IndexError: | ||
| 77 | + # in new repositories, there is no previous commit | ||
| 78 | + previous_commit = cur_commit | ||
| 79 | + #END exception handling | ||
| 84 | 80 | else: | |
| 85 | 81 | previous_commit = repo.commit(previous_commit) # obtain commit object | |
| 86 | 82 | # END handle previous commit | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,6 +149,9 @@ def test_is_valid(self): | |||
| 149 | 149 | assert self.rorepo.head.reference.is_valid() | |
| 150 | 150 | assert SymbolicReference(self.rorepo, 'hellothere').is_valid() == False | |
| 151 | 151 | ||
| 152 | + def test_orig_head(self): | ||
| 153 | + assert type(self.rorepo.head.orig_head()) == SymbolicReference | ||
| 154 | + | ||
| 152 | 155 | @with_rw_repo('0.1.6') | |
| 153 | 156 | def test_head_reset(self, rw_repo): | |
| 154 | 157 | cur_head = rw_repo.head | |
| Back | FazBrowse Home | New Git URL |
0 commit comments