diff options
author | Guido Günther <agx@sigxcpu.org> | 2009-11-22 16:05:17 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2009-11-22 16:34:52 +0100 |
commit | 043c75a1c06aa30c3b67bae6e77f7dd9dae91059 (patch) | |
tree | 2ae2bb8d80647721fd273fdafddc31bfc7b1b107 /examples | |
parent | bf258de730293694be82b1fbf2a428edd1da83db (diff) | |
download | git-buildpackage-043c75a1c06aa30c3b67bae6e77f7dd9dae91059.tar.gz git-buildpackage-043c75a1c06aa30c3b67bae6e77f7dd9dae91059.tar.bz2 git-buildpackage-043c75a1c06aa30c3b67bae6e77f7dd9dae91059.zip |
Make gbp-clone, gbp-pull and gbp-pq first class citizens
by moving them from examples/ to /usr/bin/
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/gbp-clone | 95 | ||||
-rwxr-xr-x | examples/gbp-pq | 139 | ||||
-rwxr-xr-x | examples/gbp-pull | 112 |
3 files changed, 0 insertions, 346 deletions
diff --git a/examples/gbp-clone b/examples/gbp-clone deleted file mode 100755 index 552108c9..00000000 --- a/examples/gbp-clone +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -u -# vim: set fileencoding=utf-8 : -# -# (C) 2009 Guido Guenther <agx@sigxcpu.org> -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# inspired by dom-git-checkout -# -"""clone a repo and set it up for gbp""" - -import sys -import os, os.path -from gbp.config import (GbpOptionParser, GbpOptionGroup) -from gbp.git import (GitRepositoryError, GitRepository) -from gbp.command_wrappers import (GitClone, Command, CommandExecFailed, GitBranch) -from gbp.errors import GbpError - - -def main(argv): - retval = 0 - pristine_tar_branch = 'pristine-tar' - - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] repository - clone a remote repository') - branch_group = GbpOptionGroup(parser, "branch options", "branch layout options") - parser.add_option_group(branch_group) - - branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") - branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") - branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar") - parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, - help="verbose command execution") - - (options, args) = parser.parse_args(argv) - - if len(args) != 2: - print >>sys.stderr, "Need a repository to clone.\n" - parser.print_help() - return 1 - else: - repo = args[1] - - if options.verbose: - Command.verbose = True - - try: - repo = GitRepository(os.path.curdir) - print >>sys.stderr, "Can't run inside a git repository." - return 1 - except GitRepositoryError: - pass - - - branches = [ options.debian_branch, options.upstream_branch ] - try: - GitClone()([repo]) - - (clone, dummy) = os.path.splitext(repo.rsplit('/',1)[1]) - os.chdir(clone) - - repo = GitRepository(os.path.curdir) - - if options.pristine_tar: - branches += [ pristine_tar_branch ] - - for branch in branches: - remote = 'origin/%s' % branch - if repo.has_branch(remote, remote=True) and \ - not repo.has_branch(branch): - GitBranch()(branch, remote) - - except CommandExecFailed: - retval = 1 - except GbpError, err: - if len(err.__str__()): - print >>sys.stderr, err - retval = 1 - - return retval - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - diff --git a/examples/gbp-pq b/examples/gbp-pq deleted file mode 100755 index 96b1fe6c..00000000 --- a/examples/gbp-pq +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/sh -# -# Convert a patch-queue branch into a patch series in debian/patches and vice -# versa. -# -# assumes you have your quilt patch queue for $branch on patch-queue/$branch -# -# See: https://honk.sigxcpu.org/piki/development/debian_packages_in_git/ - -is_patch_queue() -{ - local branch=$1 - - if expr $branch : patch-queue/ >/dev/null; then - return 0 - else - return 1 - fi -} - -pq_export() -{ - local branch=$1 - local pq="patch-queue/$branch" - - if is_patch_queue $branch; then - echo "On a patch-queue branch, can't redo patches." - return 1 - fi - - rm -f debian/patches/* - PATCHES=`git format-patch -N -o debian/patches $branch...$pq` - if [ -n "$PATCHES" ]; then - echo "Regenerationg patch queue in \"debian/patches\"." - > debian/patches/series - for PATCH in $PATCHES; do - # delete the first line (from sha1) and last two lines (git version - # info) of the patch file - sed -i -e '1d' -e 'N;$!P;$!D;$d' $PATCH - sed -i -e 's/^-- \n[0-9\.]+$//' $PATCH - echo $PATCH | sed -e 's%debian/patches/%%' >> debian/patches/series - done - git status -- debian/patches - else - echo "No patches on \"$pq\"." - fi -} - -pq_rebase() -{ - local branch=$1 - local pq="patch-queue/$branch" - - if ! is_patch_queue $branch; then - echo "Switching to \"$pq\"" - git checkout $pq - else - echo "Already on \"$branch\"" - fi - git rebase $branch -} - -pq_import() -{ - local branch=$1 - local pq="patch-queue/$branch" - local patches=debian/patches/ - - if is_patch_queue $branch; then - echo "Already on a patch-queue branch \"$branch\" - doing nothing." - return 1 - fi - - if ! git checkout -b $pq; then - echo "Cannot create patch-queue branch \"$pq\"." - return 1 - fi - - if [ ! -r ${patches}series ]; then - echo "Found no series file at \"$patches\". Patch-queue branch will be empty." - return 0 - fi - - QUILT_PATCHES=$patches git quiltimport -} - -pq_drop() -{ - local branch=$1 - local pq="patch-queue/$branch" - - if is_patch_queue $branch; then - echo "On a patch-queue branch, can't drop it." - return 1 - else - git branch -D ${pq} - echo "Dropped ${pq}." - fi -} - -usage () -{ - cat <<EOF -$0 [ACTION] - -Options: - export Export the associated patch-queue branch into - debian/patches and update the series file. - - import Create a patch-queue branch from debian/patches. - - rebase Switch to associated patch-queue branch and rebase - against current branch. - - drop Drop (delete) the corresponding patch-queue branch -EOF -} - -branch=$(git branch --no-color | awk '/^\*/ { print $2 }') - -case "$1" in - export) - pq_export $branch - ;; - import) - pq_import $branch - ;; - rebase) - pq_rebase $branch - ;; - drop) - pq_drop $branch - ;; - *) - usage - exit 1 - ;; -esac - diff --git a/examples/gbp-pull b/examples/gbp-pull deleted file mode 100755 index fa7fbdf3..00000000 --- a/examples/gbp-pull +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/python -u -# vim: set fileencoding=utf-8 : -# -# (C) 2009 Guido Guenther <agx@sigxcpu.org> -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# heavily inspired by dom-safe-pull which is © 2009 Stéphane Glondu <steph@glondu.net> -# -"""fast forward debian, upstream and pristine-tar branch""" - -import sys -import os, os.path -from gbp.command_wrappers import (GitFetch, GitMerge, Command, CommandExecFailed) -from gbp.config import (GbpOptionParser, GbpOptionGroup) -from gbp.errors import GbpError -from gbp.git import (GitRepositoryError, GitRepository) - -def fast_forward_branch(branch, repo, options): - remote = repo.get_merge_branch(branch) - fast_forward = repo.is_fast_forward(branch, remote) - if not fast_forward: - if options.force: - print "Non-fast forwarding '%s' due to --force" % branch - fast_forward = True - else: - print "Skipping non-fast forward of '%s' - use --force" % branch - if fast_forward: - repo.set_branch(branch) - GitMerge(remote)() - -def main(argv): - changelog = 'debian/changelog' - retval = 0 - pristine_tar = 'pristine-tar' - - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] - safely update a repository from remote') - branch_group = GbpOptionGroup(parser, "branch options", "branch layout options") - parser.add_option_group(branch_group) - branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") - branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") - branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar") - parser.add_option("--force", action="store_true", dest="force", default=False, - help="force update even if not fast forward") - parser.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False, - help="Redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch") - parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, - help="verbose command execution") - - (options, args) = parser.parse_args(argv) - - if options.verbose: - Command.verbose = True - - try: - repo = GitRepository(os.path.curdir) - except GitRepositoryError: - print >>sys.stderr, "%s is not a git repository" % (os.path.abspath('.')) - return 1 - - try: - branches = [] - current = repo.get_branch() - - for branch in [ options.debian_branch, options.upstream_branch ]: - if repo.has_branch(branch): - branches += [ branch ] - - if repo.has_branch(pristine_tar) and options.pristine_tar: - branches += [ pristine_tar ] - - (ret, out) = repo.is_clean() - if not ret: - print >>sys.stderr, "You have uncommitted changes in your source tree:" - print >>sys.stderr, out - raise GbpError - - GitFetch()() - for branch in branches: - fast_forward_branch(branch, repo, options) - - if options.redo_pq: - repo.set_branch(options.debian_branch) - Command("gbp-pq")(["drop"]) - Command("gbp-pq")(["import"]) - - repo.set_branch(current) - except CommandExecFailed: - retval = 1 - except GbpError, err: - if len(err.__str__()): - print >>sys.stderr, err - retval = 1 - - return retval - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - -# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |