-
-
Notifications
You must be signed in to change notification settings - Fork 934
Archive method does not support paths parameter #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Me too...! I've tried setting the "working_dir" but it's not used for the archive call - although this is what "git archive" actually does: if you are in a subdirectory, it will only archive the subdirectory's contents (recursively).
I have difficulties finding the "archive" method in the current master. Code search on github only produced a hit on GitPython / lib / git / repo.py (tree: 90d73cd): https://github.com/search?q=repo%3Agitpython-developers%2FGitPython+archive&repo=&langOverride=&start_value=1&type=Everything&language= (I'm feeling like I'm missing the obvious...) |
Yes, I've dug into the code but I couldn't find the appropiate place to add the neeeded argument. Maybe someone else with more understanding of the code base could throw us some pointers. What I've found is the following, but I know itsn't enough :P: git grep -n "archive(" git/db/cmd/base.py:847: def archive(self, ostream, treeish=None, prefix=None, *_kwargs): Any ideas? |
Sorry for the late reply. Looking in master is not actually recommended, as the code is bleeding edge and is not even alpha. In 0.3, what you could try instead is to just use the git command directly, maybe the following snipped helps: # resolves to git-archive --option-arg --value-arg "value"
repo.git.archive(option_arg=True, value_arg="value") You can rather easily create fancy command invocations using the git command wrapper - this way you can do everything that you can do with the commandline. In 0.3, the cmd.py module would be the place to look for more information. If you ask me, repo.archive isn't really required as the same call can be made much easier using the git command itself - it was in the interface since 0.17 though and could be considered legacy. Good luck ! |
Hi Byron, thank you for your reply which is not late at all! I've (sheepishly) tried your code without modification and this gives me:
(changed path value and added line break for readability) UPDATE: To hand over a value without option like in
something like:
seems to be the way to go? However, it returns an error which includes a git call which - when pasted into the commandline - dumps the tar stream to stdout = does what I want. So, either the command which is output by GitCommandError is not the one actually called or something else goes wrong on the way.
(path changed) Command line:
dumps the tar output. |
This actually works (work around): changing the working directory and changing back afterwards.
Note that the first line has no effect! The work around consists of the call "os.chdir" in combination with the "with_keep_cwd=True" argument to the gitrepo.archive command call. |
Hello all, So, there is no need to hack the source code or to change the current directory as @nuarhu suggested. Well done git, well done :) |
does archiving supported by github? |
You can now watch the live-coding session on youtube. |
In the following code you are not able to supply what paths you would like to archive (and not all the repo).
Meanwhile, if you use the git archive command you can suplly what paths you would like to archive.
An extra kw args could be the list of paths you want in the tar file.
The text was updated successfully, but these errors were encountered: