git.py 762 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. dever-manage tools
  5. name:git.py
  6. author:rabin
  7. """
  8. from core import *
  9. import json
  10. class Git(object):
  11. @classmethod
  12. def init(self):
  13. method = Core.getMethod(Git_Action, Args.action)
  14. method()
  15. class Git_Action(object):
  16. @staticmethod
  17. def path():
  18. return Args.name
  19. @classmethod
  20. def pull(self):
  21. path = self.path()
  22. Core.popen('cd ' + path + ' && git pull', True)
  23. @classmethod
  24. def push(self):
  25. path = self.path()
  26. if Args.param:
  27. file = Args.param
  28. else:
  29. file = '*'
  30. Core.popen('cd ' + path + ' && git commit -m "edit" '+file+' && git push -u origin master', True)
  31. @classmethod
  32. def clone(self):
  33. path = self.path()
  34. Core.popen('cd ' + path + ' && git clone ' + Args.param, True)