def test_is_releasable(self): os.makedirs('debian/') with open('debian/changelog', 'w') as f: f.write("""git-buildpackage (0.2.3) unstable; urgency=low * git doesn't like '~' in tag names so replace this with a dot when tagging -- Guido Guenther <*****@*****.**> Mon, 2 Oct 2006 18:30:20 +0200 """) source = DebianSource('.') self.assertEquals(source.changelog.distribution, "unstable") self.assertTrue(source.is_releasable())
def main(argv): retval = 1 branch = None dest = None to_push = { 'refs': [], 'tags': [], } (options, args) = parse_args(argv) if not options: return ExitCodes.parse_error if len(args) > 2: gbp.log.err("Only a single remote repository can be given") elif len(args) == 2: dest = args[1] gbp.log.setup(options.color, options.verbose, options.color_scheme) try: repo = DebianGitRepository(os.path.curdir, toplevel=False) except GitRepositoryError: gbp.log.err("%s is not inside a git repository" % (os.path.abspath('.'))) return 1 try: source = DebianSource(repo.path) branch = repo.branch if not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but %s" % (options.debian_branch, "on '%s'" % branch if branch else 'in detached HEAD state')) raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.") if not dest: dest = get_remote(repo, branch) if options.debian_tag != '': dtag = repo.version_to_tag(options.debian_tag, source.version) if repo.has_tag(dtag): to_push['tags'].append(dtag) if source.is_releasable() and branch: ref = 'refs/heads/%s' % branch to_push['refs'].append((ref, get_push_src(repo, ref, dtag))) if not source.is_native(): if options.upstream_tag != '': utag = repo.version_to_tag(options.upstream_tag, source.upstream_version) if repo.has_tag(utag): to_push['tags'].append(utag) if options.upstream_branch != '': ref = 'refs/heads/%s' % options.upstream_branch to_push['refs'].append((ref, get_push_src(repo, ref, utag))) if options.pristine_tar: commit = repo.get_pristine_tar_commit(source) if commit: ref = 'refs/heads/pristine-tar' to_push['refs'].append((ref, get_push_src(repo, ref, commit))) if do_push(repo, [dest], to_push, dry_run=options.dryrun): retval = 0 else: gbp.log.err("Failed to push some refs.") retval = 1 except (GbpError, GitRepositoryError, DebianSourceError) as err: if str(err): gbp.log.err(err) except KeyboardInterrupt: gbp.log.err("Interrupted. Aborting.") return retval
def main(argv): retval = 1 branch = None dest = None to_push = { 'refs': [], 'tags': [], } (options, args) = parse_args(argv) if not options: return ExitCodes.parse_error if len(args) > 2: gbp.log.err("Only a single remote repository can be given") elif len(args) == 2: dest = args[1] gbp.log.setup(options.color, options.verbose, options.color_scheme) try: repo = DebianGitRepository(os.path.curdir, toplevel=False) except GitRepositoryError: gbp.log.err("%s is not inside a git repository" % (os.path.abspath('.'))) return 1 try: source = DebianSource(repo.path) branch = repo.branch if not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but %s" % (options.debian_branch, "on '%s'" % branch if branch else 'in detached HEAD state')) raise GbpError( "Use --ignore-branch to ignore or --debian-branch to set the branch name." ) if not dest: dest = get_remote(repo, branch) if options.debian_tag != '': dtag = repo.version_to_tag(options.debian_tag, source.version) if repo.has_tag(dtag): to_push['tags'].append(dtag) if source.is_releasable() and branch: ref = 'refs/heads/%s' % branch to_push['refs'].append((ref, get_push_src(repo, ref, dtag))) if not source.is_native(): if options.upstream_tag != '': utag = repo.version_to_tag(options.upstream_tag, source.upstream_version) if repo.has_tag(utag): to_push['tags'].append(utag) if options.upstream_branch != '': ref = 'refs/heads/%s' % options.upstream_branch to_push['refs'].append((ref, get_push_src(repo, ref, utag))) if options.pristine_tar: commit = repo.get_pristine_tar_commit(source) if commit: ref = 'refs/heads/pristine-tar' to_push['refs'].append( (ref, get_push_src(repo, ref, commit))) if do_push(repo, [dest], to_push, dry_run=options.dryrun): retval = 0 else: gbp.log.err("Failed to push some refs.") retval = 1 except (GbpError, GitRepositoryError, DebianSourceError) as err: if str(err): gbp.log.err(err) except KeyboardInterrupt: gbp.log.err("Interrupted. Aborting.") return retval