version.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. import sys
  16. from command import Command, MirrorSafeCommand
  17. from git_command import git
  18. from git_refs import HEAD
  19. class Version(Command, MirrorSafeCommand):
  20. wrapper_version = None
  21. wrapper_path = None
  22. common = False
  23. helpSummary = "Display the version of repo"
  24. helpUsage = """
  25. %prog
  26. """
  27. def Execute(self, opt, args):
  28. rp = self.manifest.repoProject
  29. rem = rp.GetRemote(rp.remote.name)
  30. print 'repo version %s' % rp.work_git.describe(HEAD)
  31. print ' (from %s)' % rem.url
  32. if Version.wrapper_path is not None:
  33. print 'repo launcher version %s' % Version.wrapper_version
  34. print ' (from %s)' % Version.wrapper_path
  35. print git.version().strip()
  36. print 'Python %s' % sys.version