dul-daemon 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/python
  2. # dul-daemon - Simple git-daemon a like
  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. # 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.server import Backend, TCPGitServer
  21. from dulwich.repo import Repo
  22. class GitBackend(Backend):
  23. def __init__(self, gitdir):
  24. self.gitdir = gitdir
  25. self.repository = Repo(gitdir)
  26. def get_refs(self):
  27. return [tuple(refsha) for refsha in self.repository.heads().items()]
  28. def has_revision(self, sha):
  29. return False
  30. def apply_pack(self, refs, read):
  31. read()
  32. def generate_pack(self, want, have, write, progress):
  33. pass
  34. if __name__ == "__main__":
  35. backend = GitBackend(sys.argv[1])
  36. server = TCPGitServer(backend, ('localhost', 9418))
  37. server.serve_forever()