| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ Changelog | |||
| 7 | 7 | ||
| 8 | 8 | * `tag.commit` will now resolve commits deeply. | |
| 9 | 9 | * `Repo` objects can now be pickled, which helps with multi-processing. | |
| 10 | + * `Head.checkout()` now deals with detached heads, which is when it will return | ||
| 11 | + the `HEAD` reference instead. | ||
| 10 | 12 | ||
| 11 | 13 | * `DiffIndex.iter_change_type(...)` produces better results when diffing | |
| 12 | 14 | 2.0.8 - Features and Bugfixes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -202,6 +202,8 @@ def checkout(self, force=False, **kwargs): | |||
| 202 | 202 | :return: | |
| 203 | 203 | The active branch after the checkout operation, usually self unless | |
| 204 | 204 | a new branch has been created. | |
| 205 | + If there is no active branch, as the HEAD is now detached, the HEAD | ||
| 206 | + reference will be returned instead. | ||
| 205 | 207 | ||
| 206 | 208 | :note: | |
| 207 | 209 | By default it is only allowed to checkout heads - everything else | |
@@ -212,7 +214,10 @@ def checkout(self, force=False, **kwargs): | |||
| 212 | 214 | kwargs.pop('f') | |
| 213 | 215 | ||
| 214 | 216 | self.repo.git.checkout(self, **kwargs) | |
| 215 | - return self.repo.active_branch | ||
| 217 | + if self.repo.head.is_detached: | ||
| 218 | + return self.repo.head | ||
| 219 | + else: | ||
| 220 | + return self.repo.active_branch | ||
| 216 | 221 | ||
| 217 | 222 | #{ Configruation | |
| 218 | 223 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -175,6 +175,12 @@ def test_is_valid(self): | |||
| 175 | 175 | ||
| 176 | 176 | def test_orig_head(self): | |
| 177 | 177 | assert type(self.rorepo.head.orig_head()) == SymbolicReference | |
| 178 | + | ||
| 179 | + @with_rw_repo('0.1.6') | ||
| 180 | + def test_head_checkout_detached_head(self, rw_repo): | ||
| 181 | + res = rw_repo.remotes.origin.refs.master.checkout() | ||
| 182 | + assert isinstance(res, SymbolicReference) | ||
| 183 | + assert res.name == 'HEAD' | ||
| 178 | 184 | ||
| 179 | 185 | @with_rw_repo('0.1.6') | |
| 180 | 186 | def test_head_reset(self, rw_repo): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments