version.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #
  2. # Copyright (C) 2009 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from __future__ import print_function
  16. import sys
  17. from command import Command, MirrorSafeCommand
  18. from git_command import git
  19. from git_refs import HEAD
  20. class Version(Command, MirrorSafeCommand):
  21. wrapper_version = None
  22. wrapper_path = None
  23. common = False
  24. helpSummary = "Display the version of repo"
  25. helpUsage = """
  26. %prog
  27. """
  28. def Execute(self, opt, args):
  29. rp = self.manifest.repoProject
  30. rem = rp.GetRemote(rp.remote.name)
  31. print('repo version %s' % rp.work_git.describe(HEAD))
  32. print(' (from %s)' % rem.url)
  33. if Version.wrapper_path is not None:
  34. print('repo launcher version %s' % Version.wrapper_version)
  35. print(' (from %s)' % Version.wrapper_path)
  36. print(git.version().strip())
  37. print('Python %s' % sys.version)