| 1253 | return self.gl_repo.git_repo[ci_oid] |
| 1254 | |
| 1255 | def publish(self, branch): |
| 1256 | self._check_op_not_in_progress() |
| 1257 | |
| 1258 | if not isinstance(branch, RemoteBranch): # TODO: allow this |
| 1259 | raise GlError( |
| 1260 | 'Can\'t publish to a local branch (yet---this will be implemented in ' |
| 1261 | 'the future)') |
| 1262 | |
| 1263 | try: |
| 1264 | assert self.branch_name.strip() |
| 1265 | assert branch.branch_name in self.gl_repo.remotes[ |
| 1266 | branch.remote_name].listall_branches() |
| 1267 | |
| 1268 | cmd = git.push( |
| 1269 | branch.remote_name, |
| 1270 | '{0}:{1}'.format(self.branch_name, branch.branch_name)) |
| 1271 | if 'Everything up-to-date' in stderr(cmd): |
| 1272 | raise GlError('No commits to publish') |
| 1273 | except ErrorReturnCode as e: |
| 1274 | err_msg = stderr(e) |
| 1275 | if 'Updates were rejected' in err_msg: |
| 1276 | raise GlError('There are changes you need to fuse/merge') |
| 1277 | raise GlError(err_msg) |
| 1278 | |
| 1279 | |
| 1280 | # Branch helpers |