Advertisement
Guest User

git-import-dscs

a guest
Nov 3rd, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.55 KB | None | 0 0
  1. #!/bin/sh
  2. # Author: Pali Rohár
  3. # License: GPLv3+
  4. # Description: Shell script for importing Debian source packages to git (using git import-dsc)
  5. set -e
  6. test ! -d .git && git init
  7. while test "$#" != "0"; do
  8.     last="$(git show-branch --sha1-name master | sed -n 's/^\[\(.*\)\] .*/\1/p' || true)"
  9.     git branch -D upstream || true
  10.     git branch upstream || true
  11.     git import-dsc "$1"
  12.     again=0
  13.     c1="$(git show-branch --sha1-name master | sed -n 's/^\[\(.*\)\] .*/\1/p')"
  14.     if test "$c1" = "$last"; then
  15.         git merge upstream || true
  16.     fi
  17.     DATE="$(dpkg-parsechangelog | sed -n 's/Date: //p')"
  18.     AUTHOR="$(dpkg-parsechangelog | sed -n 's/Maintainer: //p')"
  19.     if git show-branch upstream; then
  20.         c2="$(git show-branch --sha1-name upstream | sed -n 's/^\[\(.*\)\] .*/\1/p')"
  21.         if test "$c1" != "$last" -a "$c2" != "$last" -a "$c1" != "$c2"; then
  22.             again=1
  23.             git tag -d $(git tag --contains master)
  24.             git reset --hard upstream
  25.         fi
  26.         git branch -d upstream
  27.     fi
  28.     if git show-branch HEAD^ && ! test -d debian; then
  29.         git checkout HEAD^ -- debian || true
  30.         git add debian || true
  31.         TAGS="$(git tag --contains master)"
  32.         git tag -d $TAGS
  33.         EDITOR=true git commit --amend
  34.         for tag in $TAGS; do git tag $tag; done
  35.     fi
  36.     if ! test -z "$DATE" -o -z "$AUTHOR"; then
  37.         TAGS="$(git tag --contains master)"
  38.         git tag -d $TAGS
  39.         EDITOR=true git commit --amend --date="$DATE" --author="$AUTHOR"
  40.         for tag in $TAGS; do git tag $tag; done
  41.     fi
  42.     if test "$again" = "1"; then
  43.         git branch upstream
  44.         git clean -f
  45.         git import-dsc "$1"
  46.         git branch -d upstream
  47.     fi
  48.     shift
  49. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement