cmd_clone.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/python -tt
  2. # vim: ai ts=4 sts=4 et sw=4
  3. #
  4. # Copyright (c) 2013 Intel, Inc.
  5. #
  6. # This program is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by the Free
  8. # Software Foundation; version 2 of the License
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. # for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along
  16. # with this program; if not, write to the Free Software Foundation, Inc., 59
  17. # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. """Implementation of subcmd: clone
  19. """
  20. from gitbuildsys.conf import configmgr
  21. from gitbuildsys.errors import GbsError
  22. from gitbuildsys.log import LOGGER as log
  23. from gitbuildsys.log import waiting
  24. from gbp.scripts.clone import main as gbp_clone
  25. @waiting
  26. def do_clone(*args, **kwargs):
  27. """Wrapper for gbp-clone, prints a progress indicator"""
  28. return gbp_clone(*args, **kwargs)
  29. def main(args):
  30. """gbs clone entry point."""
  31. # Determine upstream branch
  32. upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
  33. packaging_branch = configmgr.get_arg_conf(args, 'packaging_branch')
  34. # Construct GBP cmdline arguments
  35. gbp_args = ['dummy argv[0]',
  36. '--color-scheme=magenta:green:yellow:red',
  37. '--pristine-tar',
  38. '--upstream-branch=%s' % upstream_branch,
  39. '--packaging-branch=%s' % packaging_branch]
  40. if args.all:
  41. gbp_args.append('--all')
  42. if args.depth:
  43. gbp_args.append('--depth=%s' % args.depth)
  44. if args.debug:
  45. gbp_args.append("--verbose")
  46. gbp_args.append(args.uri)
  47. if args.directory:
  48. gbp_args.append(args.directory)
  49. # Clone
  50. log.info('cloning %s' % args.uri)
  51. if do_clone(gbp_args):
  52. raise GbsError('Failed to clone %s' % args.uri)
  53. log.info('finished')