| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,12 @@ Blob | |||
| 50 | 50 | ---- | |
| 51 | 51 | * former 'name' member renamed to path as it suits the actual data better | |
| 52 | 52 | ||
| 53 | + GitCommand | ||
| 54 | + ----------- | ||
| 55 | + * git.subcommand call scheme now prunes out None from the argument list, allowing | ||
| 56 | + to be called more confortably as None can never be a valid to the git command | ||
| 57 | + if converted to a string. | ||
| 58 | + | ||
| 53 | 59 | Commit | |
| 54 | 60 | ------ | |
| 55 | 61 | * 'count' method is not an instance method to increase its ease of use | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,11 @@ Index | |||
| 41 | 41 | * Index Merge ( merge two trees into the index to quickly see conflicts ). | |
| 42 | 42 | Its possible to write it into a separate index file that can be read separately. | |
| 43 | 43 | ||
| 44 | + Remote | ||
| 45 | + ------ | ||
| 46 | + * 'push' method needs a test, a true test repository is required though, a fork | ||
| 47 | + of a fork would do :)! | ||
| 48 | + | ||
| 44 | 49 | Repo | |
| 45 | 50 | ---- | |
| 46 | 51 | * Nice fetch/pull handling, at least supported/wired throuhg to the git command | |
@@ -66,5 +71,6 @@ Testing | |||
| 66 | 71 | read-only testing scheme that operates on the own repository. Doing this could be a simple | |
| 67 | 72 | as forking a shared repo in a tmp directory. In that moment, we probably want to | |
| 68 | 73 | facility committing and checkouts as well. | |
| 74 | + - Use these tests for git-remote as we need to test push | ||
| 69 | 75 | ||
| 70 | 76 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -261,7 +261,9 @@ def _call_process(self, method, *args, **kwargs): | |||
| 261 | 261 | such as in 'ls_files' to call 'ls-files'. | |
| 262 | 262 | ||
| 263 | 263 | ``args`` | |
| 264 | - is the list of arguments | ||
| 264 | + is the list of arguments. If None is included, it will be pruned. | ||
| 265 | + This allows your commands to call git more conveniently as None | ||
| 266 | + is realized as non-existent | ||
| 265 | 267 | ||
| 266 | 268 | ``kwargs`` | |
| 267 | 269 | is a dict of keyword arguments. | |
@@ -287,7 +289,7 @@ def _call_process(self, method, *args, **kwargs): | |||
| 287 | 289 | # Prepare the argument list | |
| 288 | 290 | opt_args = self.transform_kwargs(**kwargs) | |
| 289 | 291 | ||
| 290 | - ext_args = self.__unpack_args(args) | ||
| 292 | + ext_args = self.__unpack_args([a for a in args if a is not None]) | ||
| 291 | 293 | args = opt_args + ext_args | |
| 292 | 294 | ||
| 293 | 295 | call = ["git", dashify(method)] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,7 +185,9 @@ def rename(self, new_name): | |||
| 185 | 185 | ||
| 186 | 186 | def update(self, **kwargs): | |
| 187 | 187 | """ | |
| 188 | - Fetch all changes for this remote, including new branches | ||
| 188 | + Fetch all changes for this remote, including new branches which will | ||
| 189 | + be forced in ( in case your local remote branch is not part the new remote branches | ||
| 190 | + ancestry anymore ). | ||
| 189 | 191 | ||
| 190 | 192 | ``kwargs`` | |
| 191 | 193 | Additional arguments passed to git-remote update | |
@@ -196,6 +198,64 @@ def update(self, **kwargs): | |||
| 196 | 198 | self.repo.git.remote("update", self.name) | |
| 197 | 199 | return self | |
| 198 | 200 | ||
| 201 | + def fetch(self, refspec=None, **kwargs): | ||
| 202 | + """ | ||
| 203 | + Fetch the latest changes for this remote | ||
| 204 | + | ||
| 205 | + ``refspec`` | ||
| 206 | + A "refspec" is used by fetch and push to describe the mapping | ||
| 207 | + between remote ref and local ref. They are combined with a colon in | ||
| 208 | + the format <src>:<dst>, preceded by an optional plus sign, +. | ||
| 209 | + For example: git fetch $URL refs/heads/master:refs/heads/origin means | ||
| 210 | + "grab the master branch head from the $URL and store it as my origin | ||
| 211 | + branch head". And git push $URL refs/heads/master:refs/heads/to-upstream | ||
| 212 | + means "publish my master branch head as to-upstream branch at $URL". | ||
| 213 | + See also git-push(1). | ||
| 214 | + | ||
| 215 | + Taken from the git manual | ||
| 216 | + | ||
| 217 | + ``**kwargs`` | ||
| 218 | + Additional arguments to be passed to git-fetch | ||
| 219 | + | ||
| 220 | + Returns | ||
| 221 | + self | ||
| 222 | + """ | ||
| 223 | + self.repo.git.fetch(self, refspec, **kwargs) | ||
| 224 | + return self | ||
| 225 | + | ||
| 226 | + def pull(self, refspec=None, **kwargs): | ||
| 227 | + """ | ||
| 228 | + Pull changes from the given branch, being the same as a fetch followed | ||
| 229 | + by a merge of branch with your local branch. | ||
| 230 | + | ||
| 231 | + ``refspec`` | ||
| 232 | + see 'fetch' method | ||
| 233 | + | ||
| 234 | + ``**kwargs`` | ||
| 235 | + Additional arguments to be passed to git-pull | ||
| 236 | + | ||
| 237 | + Returns | ||
| 238 | + self | ||
| 239 | + """ | ||
| 240 | + self.repo.git.pull(self, refspec, **kwargs) | ||
| 241 | + return self | ||
| 242 | + | ||
| 243 | + def push(self, refspec=None, **kwargs): | ||
| 244 | + """ | ||
| 245 | + Push changes from source branch in refspec to target branch in refspec. | ||
| 246 | + | ||
| 247 | + ``refspec`` | ||
| 248 | + see 'fetch' method | ||
| 249 | + | ||
| 250 | + ``**kwargs`` | ||
| 251 | + Additional arguments to be passed to git-push | ||
| 252 | + | ||
| 253 | + Returns | ||
| 254 | + self | ||
| 255 | + """ | ||
| 256 | + self.repo.git.push(self, refspec, **kwargs) | ||
| 257 | + return self | ||
| 258 | + | ||
| 199 | 259 | @property | |
| 200 | 260 | def config_reader(self): | |
| 201 | 261 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,8 @@ def test_base(self): | |||
| 32 | 32 | # END for each ref | |
| 33 | 33 | ||
| 34 | 34 | # OPTIONS | |
| 35 | - for opt in ("url", "fetch"): | ||
| 35 | + # cannot use 'fetch' key anymore as it is now a method | ||
| 36 | + for opt in ("url", ): | ||
| 36 | 37 | val = getattr(remote, opt) | |
| 37 | 38 | reader = remote.config_reader | |
| 38 | 39 | assert reader.get(opt) == val | |
@@ -61,8 +62,10 @@ def test_base(self): | |||
| 61 | 62 | assert remote.rename(prev_name).name == prev_name | |
| 62 | 63 | # END for each rename ( back to prev_name ) | |
| 63 | 64 | ||
| 65 | + remote.fetch() | ||
| 66 | + self.failUnlessRaises(GitCommandError, remote.pull) | ||
| 64 | 67 | remote.update() | |
| 65 | - | ||
| 68 | + self.fail("test push once there is a test-repo") | ||
| 66 | 69 | # END for each remote | |
| 67 | 70 | assert num_remotes | |
| 68 | 71 | assert num_remotes == len(remote_set) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments