dul-receive-pack 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/python
  2. # dul-receive-pack - git-receive-pack in python
  3. # Copyright (C) 2008 John Carr <john.carr@unrouted.co.uk>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; version 2
  8. # or (at your option) a later version of the License.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  18. # MA 02110-1301, USA.
  19. import sys
  20. from dulwich.repo import Repo
  21. from dulwich.server import GitBackend, ReceivePackHandler
  22. def send_fn(data):
  23. sys.stdout.write(data)
  24. sys.stdout.flush()
  25. if __name__ == "__main__":
  26. gitdir = None
  27. if len(sys.argv) > 1:
  28. gitdir = sys.argv[1]
  29. backend = GitBackend(Repo(gitdir))
  30. handler = ReceivePackHandler(backend, sys.stdin.read, send_fn)
  31. handler.handle()