cmd_pull.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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: pull
  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.pull import main as gbp_pull
  25. @waiting
  26. def do_pull(*args, **kwargs):
  27. """Wrapper for gbp-pull, prints a progress indicator"""
  28. return gbp_pull(*args, **kwargs)
  29. def main(args):
  30. """gbs pull entry point."""
  31. # Determine upstream branch
  32. upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
  33. # Construct GBP cmdline arguments
  34. gbp_args = ['dummy argv[0]',
  35. '--color-scheme=magenta:green:yellow:red',
  36. '--pristine-tar',
  37. '--upstream-branch=%s' % upstream_branch,
  38. '--packaging-branch=master']
  39. if args.depth:
  40. gbp_args.append('--depth=%s' % args.depth)
  41. if args.force:
  42. gbp_args.append('--force=clean')
  43. if args.all:
  44. gbp_args.append('--all')
  45. if args.debug:
  46. gbp_args.append("--verbose")
  47. # Clone
  48. log.info('updating from remote')
  49. ret = do_pull(gbp_args)
  50. if ret == 2:
  51. raise GbsError('Failed to update some of the branches!')
  52. elif ret:
  53. raise GbsError('Update failed!')
  54. log.info('finished')