File: git-snapshot.sh

package info (click to toggle)
pidgin-sipe 1.25.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,052 kB
  • sloc: ansic: 52,128; objc: 980; makefile: 662; lex: 357; perl: 335; sh: 284; xml: 30
file content (45 lines) | stat: -rwxr-xr-x 1,246 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#
# Take a snapshot of the current pidgin-sipe git HEAD from the mob branch.
#
# You can specify the path to a local repository to speed up the cloning
# process. The output will be a bzip2 compressed tarball whose name includes
# the current date and the abbreviated commit object name of HEAD.
#
# Adapted from several examples found on the Internet.
#
# Configuration
PROJECT=pidgin-sipe
REPOSITORY="git+ssh://mob@repo.or.cz/srv/git/siplcs.git"
BRANCH=mob

# Create clone
set -e
TODAY=$(date +%Y%m%d)
CLONEDIR=${PROJECT}-${TODAY}
echo "Clone directory '$CLONEDIR'."
REFERENCE=${1:+--reference $1}
if [ -n "$1" ]; then
    echo "Using local repository under '$1'."
fi
if [ -n "$2" ]; then
    REPOSITORY=$2
fi
echo "Cloning from repository URL '$REPOSITORY'."
rm -rf $CLONEDIR
git clone -n $REFERENCE $REPOSITORY $CLONEDIR
cd $CLONEDIR
git checkout -q -b $CLONEDIR origin/$BRANCH

# Create archive
COMMIT=$(git log -n 1 --abbrev-commit --pretty=oneline | cut -d' ' -f1| sed -e 's/\.//g')
PREFIX=${PROJECT}-${TODAY}git${COMMIT}
ARCHIVE=${PREFIX}.tar.bz2
echo "Creating archive '$ARCHIVE'..."
git archive --format=tar --prefix=$PREFIX/ HEAD | bzip2 >../${PREFIX}.tar.bz2

# Cleanup
echo "Cleanup..."
cd ..
rm -rf $CLONEDIR
echo "DONE."