The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 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 | |
Shawn O. Pearce | 2a1ccb2 | 2009-04-10 16:51:53 -0700 | [diff] [blame] | 16 | from optparse import SUPPRESS_HELP |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 17 | import os |
| 18 | import re |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 19 | import shutil |
Nico Sallembien | a1bfd2c | 2010-04-06 10:40:01 -0700 | [diff] [blame^] | 20 | import socket |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 21 | import subprocess |
| 22 | import sys |
Shawn O. Pearce | f690687 | 2009-04-18 10:49:00 -0700 | [diff] [blame] | 23 | import time |
Nico Sallembien | a1bfd2c | 2010-04-06 10:40:01 -0700 | [diff] [blame^] | 24 | import xmlrpclib |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 25 | |
| 26 | from git_command import GIT |
Shawn O. Pearce | e756c41 | 2009-04-13 11:51:15 -0700 | [diff] [blame] | 27 | from project import HEAD |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 28 | from project import Project |
| 29 | from project import RemoteSpec |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 30 | from command import Command, MirrorSafeCommand |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 31 | from error import RepoChangedException, GitError |
| 32 | from project import R_HEADS |
Shawn O. Pearce | 350cde4 | 2009-04-16 11:21:18 -0700 | [diff] [blame] | 33 | from project import SyncBuffer |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 34 | from progress import Progress |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 35 | |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 36 | class Sync(Command, MirrorSafeCommand): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 37 | common = True |
| 38 | helpSummary = "Update working tree to the latest revision" |
| 39 | helpUsage = """ |
| 40 | %prog [<project>...] |
| 41 | """ |
| 42 | helpDescription = """ |
| 43 | The '%prog' command synchronizes local project directories |
| 44 | with the remote repositories specified in the manifest. If a local |
| 45 | project does not yet exist, it will clone a new local directory from |
| 46 | the remote repository and set up tracking branches as specified in |
| 47 | the manifest. If the local project already exists, '%prog' |
| 48 | will update the remote branches and rebase any new local changes |
| 49 | on top of the new remote changes. |
| 50 | |
| 51 | '%prog' will synchronize all projects listed at the command |
| 52 | line. Projects can be specified either by name, or by a relative |
| 53 | or absolute path to the project's local directory. If no projects |
| 54 | are specified, '%prog' will synchronize all projects listed in |
| 55 | the manifest. |
Shawn O. Pearce | 3e768c9 | 2009-04-10 16:59:36 -0700 | [diff] [blame] | 56 | |
| 57 | The -d/--detach option can be used to switch specified projects |
| 58 | back to the manifest revision. This option is especially helpful |
| 59 | if the project is currently on a topic branch, but the manifest |
| 60 | revision is temporarily needed. |
Shawn O. Pearce | eb7af87 | 2009-04-21 08:02:04 -0700 | [diff] [blame] | 61 | |
Nico Sallembien | a1bfd2c | 2010-04-06 10:40:01 -0700 | [diff] [blame^] | 62 | The -s/--smart-sync option can be used to sync to a known good |
| 63 | build as specified by the manifest-server element in the current |
| 64 | manifest. |
| 65 | |
Shawn O. Pearce | eb7af87 | 2009-04-21 08:02:04 -0700 | [diff] [blame] | 66 | SSH Connections |
| 67 | --------------- |
| 68 | |
| 69 | If at least one project remote URL uses an SSH connection (ssh://, |
| 70 | git+ssh://, or user@host:path syntax) repo will automatically |
| 71 | enable the SSH ControlMaster option when connecting to that host. |
| 72 | This feature permits other projects in the same '%prog' session to |
| 73 | reuse the same SSH tunnel, saving connection setup overheads. |
| 74 | |
| 75 | To disable this behavior on UNIX platforms, set the GIT_SSH |
| 76 | environment variable to 'ssh'. For example: |
| 77 | |
| 78 | export GIT_SSH=ssh |
| 79 | %prog |
| 80 | |
| 81 | Compatibility |
| 82 | ~~~~~~~~~~~~~ |
| 83 | |
| 84 | This feature is automatically disabled on Windows, due to the lack |
| 85 | of UNIX domain socket support. |
| 86 | |
| 87 | This feature is not compatible with url.insteadof rewrites in the |
| 88 | user's ~/.gitconfig. '%prog' is currently not able to perform the |
| 89 | rewrite early enough to establish the ControlMaster tunnel. |
| 90 | |
| 91 | If the remote SSH daemon is Gerrit Code Review, version 2.0.10 or |
| 92 | later is required to fix a server side protocol bug. |
| 93 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 94 | """ |
| 95 | |
| 96 | def _Options(self, p): |
Shawn O. Pearce | b1562fa | 2009-04-10 17:04:08 -0700 | [diff] [blame] | 97 | p.add_option('-l','--local-only', |
| 98 | dest='local_only', action='store_true', |
| 99 | help="only update working tree, don't fetch") |
Shawn O. Pearce | 96fdcef | 2009-04-10 16:29:20 -0700 | [diff] [blame] | 100 | p.add_option('-n','--network-only', |
| 101 | dest='network_only', action='store_true', |
| 102 | help="fetch only, don't update working tree") |
Shawn O. Pearce | 3e768c9 | 2009-04-10 16:59:36 -0700 | [diff] [blame] | 103 | p.add_option('-d','--detach', |
| 104 | dest='detach_head', action='store_true', |
| 105 | help='detach projects back to manifest revision') |
Nico Sallembien | a1bfd2c | 2010-04-06 10:40:01 -0700 | [diff] [blame^] | 106 | p.add_option('-s', '--smart-sync', |
| 107 | dest='smart_sync', action='store_true', |
| 108 | help='smart sync using manifest from a known good build') |
Shawn O. Pearce | 3e768c9 | 2009-04-10 16:59:36 -0700 | [diff] [blame] | 109 | |
Shawn O. Pearce | fd89b67 | 2009-04-18 11:28:57 -0700 | [diff] [blame] | 110 | g = p.add_option_group('repo Version options') |
| 111 | g.add_option('--no-repo-verify', |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 112 | dest='no_repo_verify', action='store_true', |
| 113 | help='do not verify repo source code') |
Shawn O. Pearce | fd89b67 | 2009-04-18 11:28:57 -0700 | [diff] [blame] | 114 | g.add_option('--repo-upgraded', |
Shawn O. Pearce | c9ef744 | 2008-11-03 10:32:09 -0800 | [diff] [blame] | 115 | dest='repo_upgraded', action='store_true', |
Shawn O. Pearce | 2a1ccb2 | 2009-04-10 16:51:53 -0700 | [diff] [blame] | 116 | help=SUPPRESS_HELP) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 117 | |
Shawn O. Pearce | f690687 | 2009-04-18 10:49:00 -0700 | [diff] [blame] | 118 | def _Fetch(self, projects): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 119 | fetched = set() |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 120 | pm = Progress('Fetching projects', len(projects)) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 121 | for project in projects: |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 122 | pm.update() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 123 | if project.Sync_NetworkHalf(): |
| 124 | fetched.add(project.gitdir) |
| 125 | else: |
| 126 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name |
| 127 | sys.exit(1) |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 128 | pm.end() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 129 | return fetched |
| 130 | |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 131 | def UpdateProjectList(self): |
| 132 | new_project_paths = [] |
| 133 | for project in self.manifest.projects.values(): |
Shawn O. Pearce | 3a68bb4 | 2009-06-04 16:18:09 -0700 | [diff] [blame] | 134 | if project.relpath: |
| 135 | new_project_paths.append(project.relpath) |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 136 | file_name = 'project.list' |
| 137 | file_path = os.path.join(self.manifest.repodir, file_name) |
| 138 | old_project_paths = [] |
| 139 | |
| 140 | if os.path.exists(file_path): |
| 141 | fd = open(file_path, 'r') |
| 142 | try: |
| 143 | old_project_paths = fd.read().split('\n') |
| 144 | finally: |
| 145 | fd.close() |
| 146 | for path in old_project_paths: |
Shawn O. Pearce | 3a68bb4 | 2009-06-04 16:18:09 -0700 | [diff] [blame] | 147 | if not path: |
| 148 | continue |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 149 | if path not in new_project_paths: |
| 150 | project = Project( |
| 151 | manifest = self.manifest, |
| 152 | name = path, |
| 153 | remote = RemoteSpec('origin'), |
| 154 | gitdir = os.path.join(self.manifest.topdir, |
| 155 | path, '.git'), |
| 156 | worktree = os.path.join(self.manifest.topdir, path), |
| 157 | relpath = path, |
| 158 | revisionExpr = 'HEAD', |
| 159 | revisionId = None) |
| 160 | if project.IsDirty(): |
| 161 | print >>sys.stderr, 'error: Cannot remove project "%s": \ |
| 162 | uncommitted changes are present' % project.relpath |
| 163 | print >>sys.stderr, ' commit changes, then run sync again' |
| 164 | return -1 |
| 165 | else: |
| 166 | print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree |
| 167 | shutil.rmtree(project.worktree) |
Jaikumar Ganesh | 8135cdc | 2009-06-02 15:07:44 -0700 | [diff] [blame] | 168 | # Try deleting parent subdirs if they are empty |
| 169 | dir = os.path.dirname(project.worktree) |
| 170 | while dir != self.manifest.topdir: |
| 171 | try: |
| 172 | os.rmdir(dir) |
| 173 | except OSError: |
| 174 | break |
| 175 | dir = os.path.dirname(dir) |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 176 | |
Shawn O. Pearce | 9fb29ce | 2009-06-04 20:41:02 -0700 | [diff] [blame] | 177 | new_project_paths.sort() |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 178 | fd = open(file_path, 'w') |
| 179 | try: |
| 180 | fd.write('\n'.join(new_project_paths)) |
Shawn O. Pearce | 3a68bb4 | 2009-06-04 16:18:09 -0700 | [diff] [blame] | 181 | fd.write('\n') |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 182 | finally: |
| 183 | fd.close() |
| 184 | return 0 |
| 185 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 186 | def Execute(self, opt, args): |
Shawn O. Pearce | 3e768c9 | 2009-04-10 16:59:36 -0700 | [diff] [blame] | 187 | if opt.network_only and opt.detach_head: |
| 188 | print >>sys.stderr, 'error: cannot combine -n and -d' |
| 189 | sys.exit(1) |
Shawn O. Pearce | b1562fa | 2009-04-10 17:04:08 -0700 | [diff] [blame] | 190 | if opt.network_only and opt.local_only: |
| 191 | print >>sys.stderr, 'error: cannot combine -n and -l' |
| 192 | sys.exit(1) |
Shawn O. Pearce | 3e768c9 | 2009-04-10 16:59:36 -0700 | [diff] [blame] | 193 | |
Nico Sallembien | a1bfd2c | 2010-04-06 10:40:01 -0700 | [diff] [blame^] | 194 | if opt.smart_sync: |
| 195 | if not self.manifest.manifest_server: |
| 196 | print >>sys.stderr, \ |
| 197 | 'error: cannot smart sync: no manifest server defined in manifest' |
| 198 | sys.exit(1) |
| 199 | try: |
| 200 | server = xmlrpclib.Server(self.manifest.manifest_server) |
| 201 | p = self.manifest.manifestProject |
| 202 | b = p.GetBranch(p.CurrentBranch) |
| 203 | branch = b.merge |
| 204 | |
| 205 | env = dict(os.environ) |
| 206 | if (env.has_key('TARGET_PRODUCT') and |
| 207 | env.has_key('TARGET_BUILD_VARIANT')): |
| 208 | target = '%s-%s' % (env['TARGET_PRODUCT'], |
| 209 | env['TARGET_BUILD_VARIANT']) |
| 210 | [success, manifest_str] = server.GetApprovedManifest(branch, target) |
| 211 | else: |
| 212 | [success, manifest_str] = server.GetApprovedManifest(branch) |
| 213 | |
| 214 | if success: |
| 215 | manifest_name = "smart_sync_override.xml" |
| 216 | manifest_path = os.path.join(self.manifest.manifestProject.worktree, |
| 217 | manifest_name) |
| 218 | try: |
| 219 | f = open(manifest_path, 'w') |
| 220 | try: |
| 221 | f.write(manifest_str) |
| 222 | self.manifest.Override(manifest_name) |
| 223 | finally: |
| 224 | f.close() |
| 225 | except IOError: |
| 226 | print >>sys.stderr, 'error: cannot write manifest to %s' % \ |
| 227 | manifest_path |
| 228 | sys.exit(1) |
| 229 | else: |
| 230 | print >>sys.stderr, 'error: %s' % manifest_str |
| 231 | sys.exit(1) |
| 232 | except socket.error: |
| 233 | print >>sys.stderr, 'error: cannot connect to manifest server %s' % ( |
| 234 | self.manifest.manifest_server) |
| 235 | sys.exit(1) |
| 236 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 237 | rp = self.manifest.repoProject |
| 238 | rp.PreSync() |
| 239 | |
| 240 | mp = self.manifest.manifestProject |
| 241 | mp.PreSync() |
| 242 | |
Shawn O. Pearce | c9ef744 | 2008-11-03 10:32:09 -0800 | [diff] [blame] | 243 | if opt.repo_upgraded: |
Shawn O. Pearce | e756c41 | 2009-04-13 11:51:15 -0700 | [diff] [blame] | 244 | _PostRepoUpgrade(self.manifest) |
Shawn O. Pearce | c9ef744 | 2008-11-03 10:32:09 -0800 | [diff] [blame] | 245 | |
Nico Sallembien | 9bb1816 | 2009-12-07 15:38:01 -0800 | [diff] [blame] | 246 | if not opt.local_only: |
| 247 | mp.Sync_NetworkHalf() |
| 248 | |
| 249 | if mp.HasChanges: |
| 250 | syncbuf = SyncBuffer(mp.config) |
| 251 | mp.Sync_LocalHalf(syncbuf) |
| 252 | if not syncbuf.Finish(): |
| 253 | sys.exit(1) |
| 254 | self.manifest._Unload() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 255 | all = self.GetProjects(args, missing_ok=True) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 256 | |
Shawn O. Pearce | b1562fa | 2009-04-10 17:04:08 -0700 | [diff] [blame] | 257 | if not opt.local_only: |
Shawn O. Pearce | f690687 | 2009-04-18 10:49:00 -0700 | [diff] [blame] | 258 | to_fetch = [] |
| 259 | now = time.time() |
| 260 | if (24 * 60 * 60) <= (now - rp.LastFetch): |
| 261 | to_fetch.append(rp) |
Shawn O. Pearce | f690687 | 2009-04-18 10:49:00 -0700 | [diff] [blame] | 262 | to_fetch.extend(all) |
| 263 | |
| 264 | fetched = self._Fetch(to_fetch) |
Shawn O. Pearce | e756c41 | 2009-04-13 11:51:15 -0700 | [diff] [blame] | 265 | _PostRepoFetch(rp, opt.no_repo_verify) |
Shawn O. Pearce | b1562fa | 2009-04-10 17:04:08 -0700 | [diff] [blame] | 266 | if opt.network_only: |
| 267 | # bail out now; the rest touches the working tree |
| 268 | return |
| 269 | |
Shawn O. Pearce | b1562fa | 2009-04-10 17:04:08 -0700 | [diff] [blame] | 270 | self.manifest._Unload() |
| 271 | all = self.GetProjects(args, missing_ok=True) |
| 272 | missing = [] |
| 273 | for project in all: |
| 274 | if project.gitdir not in fetched: |
| 275 | missing.append(project) |
Shawn O. Pearce | f690687 | 2009-04-18 10:49:00 -0700 | [diff] [blame] | 276 | self._Fetch(missing) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 277 | |
Shawn O. Pearce | cd1d7ff | 2009-06-04 16:15:53 -0700 | [diff] [blame] | 278 | if self.manifest.IsMirror: |
| 279 | # bail out now, we have no working tree |
| 280 | return |
| 281 | |
Jaikumar Ganesh | 4f2517f | 2009-06-01 21:10:33 -0700 | [diff] [blame] | 282 | if self.UpdateProjectList(): |
| 283 | sys.exit(1) |
| 284 | |
Shawn O. Pearce | 350cde4 | 2009-04-16 11:21:18 -0700 | [diff] [blame] | 285 | syncbuf = SyncBuffer(mp.config, |
| 286 | detach_head = opt.detach_head) |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 287 | pm = Progress('Syncing work tree', len(all)) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 288 | for project in all: |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 289 | pm.update() |
Shawn O. Pearce | e284ad1 | 2008-11-04 07:37:10 -0800 | [diff] [blame] | 290 | if project.worktree: |
Shawn O. Pearce | 350cde4 | 2009-04-16 11:21:18 -0700 | [diff] [blame] | 291 | project.Sync_LocalHalf(syncbuf) |
Shawn O. Pearce | 68194f4 | 2009-04-10 16:48:52 -0700 | [diff] [blame] | 292 | pm.end() |
Shawn O. Pearce | 350cde4 | 2009-04-16 11:21:18 -0700 | [diff] [blame] | 293 | print >>sys.stderr |
| 294 | if not syncbuf.Finish(): |
| 295 | sys.exit(1) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 296 | |
Shawn O. Pearce | e756c41 | 2009-04-13 11:51:15 -0700 | [diff] [blame] | 297 | def _PostRepoUpgrade(manifest): |
| 298 | for project in manifest.projects.values(): |
| 299 | if project.Exists: |
| 300 | project.PostRepoUpgrade() |
| 301 | |
| 302 | def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): |
| 303 | if rp.HasChanges: |
| 304 | print >>sys.stderr, 'info: A new version of repo is available' |
| 305 | print >>sys.stderr, '' |
| 306 | if no_repo_verify or _VerifyTag(rp): |
Shawn O. Pearce | 350cde4 | 2009-04-16 11:21:18 -0700 | [diff] [blame] | 307 | syncbuf = SyncBuffer(rp.config) |
| 308 | rp.Sync_LocalHalf(syncbuf) |
| 309 | if not syncbuf.Finish(): |
Shawn O. Pearce | e756c41 | 2009-04-13 11:51:15 -0700 | [diff] [blame] | 310 | sys.exit(1) |
| 311 | print >>sys.stderr, 'info: Restarting repo with latest version' |
| 312 | raise RepoChangedException(['--repo-upgraded']) |
| 313 | else: |
| 314 | print >>sys.stderr, 'warning: Skipped upgrade to unverified version' |
| 315 | else: |
| 316 | if verbose: |
| 317 | print >>sys.stderr, 'repo version %s is current' % rp.work_git.describe(HEAD) |
| 318 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 319 | def _VerifyTag(project): |
| 320 | gpg_dir = os.path.expanduser('~/.repoconfig/gnupg') |
| 321 | if not os.path.exists(gpg_dir): |
| 322 | print >>sys.stderr,\ |
| 323 | """warning: GnuPG was not available during last "repo init" |
| 324 | warning: Cannot automatically authenticate repo.""" |
| 325 | return True |
| 326 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 327 | try: |
Shawn O. Pearce | 3c8dea1 | 2009-05-29 18:38:17 -0700 | [diff] [blame] | 328 | cur = project.bare_git.describe(project.GetRevisionId()) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 329 | except GitError: |
| 330 | cur = None |
| 331 | |
| 332 | if not cur \ |
| 333 | or re.compile(r'^.*-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur): |
Shawn O. Pearce | 3c8dea1 | 2009-05-29 18:38:17 -0700 | [diff] [blame] | 334 | rev = project.revisionExpr |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 335 | if rev.startswith(R_HEADS): |
| 336 | rev = rev[len(R_HEADS):] |
| 337 | |
| 338 | print >>sys.stderr |
| 339 | print >>sys.stderr,\ |
| 340 | "warning: project '%s' branch '%s' is not signed" \ |
| 341 | % (project.name, rev) |
| 342 | return False |
| 343 | |
| 344 | env = dict(os.environ) |
| 345 | env['GIT_DIR'] = project.gitdir |
| 346 | env['GNUPGHOME'] = gpg_dir |
| 347 | |
| 348 | cmd = [GIT, 'tag', '-v', cur] |
| 349 | proc = subprocess.Popen(cmd, |
| 350 | stdout = subprocess.PIPE, |
| 351 | stderr = subprocess.PIPE, |
| 352 | env = env) |
| 353 | out = proc.stdout.read() |
| 354 | proc.stdout.close() |
| 355 | |
| 356 | err = proc.stderr.read() |
| 357 | proc.stderr.close() |
| 358 | |
| 359 | if proc.wait() != 0: |
| 360 | print >>sys.stderr |
| 361 | print >>sys.stderr, out |
| 362 | print >>sys.stderr, err |
| 363 | print >>sys.stderr |
| 364 | return False |
| 365 | return True |