-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgbp-debianize-gitrepo
executable file
·69 lines (56 loc) · 2.54 KB
/
gbp-debianize-gitrepo
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Arguments : none
# All is guessed from the git repo from inside which it is launched.
# Output : - if a debian/ folder already exists, error is raised.
# - else, at the root of the git repo a debian/ directory is created, with the branch master, and original git is copied on branch upstream.
# Get repository name: it is the current git repo directory name
root_repo_path="$(git rev-parse --show-toplevel)"
repo_name="$(basename $root_repo_path)"
### Guess version number (from tags)
## if there is a current tag and it is unique, take it as a version
## if not unique, take the one with numbers in it
## if several have numbers, take the smallest one by lexicographical order
## else, maybe take the previous one, if unique, and same rules if non unique/
## if no tag at all, create one called 0.1 (with git tag), and use it for "version"
#last_tags=$(git tags --points-at "HEAD~$iteration") #this will require git >= 1.7.10
all_tags=$(git tag)
pseudo_last_tags=$(git log --decorate --tags --no-walk | grep ^commit | awk '{$1=$2="";print $0}' | perl -ne 's/^ *\(// ; s/\) *$// ; s/(, *|^)HEAD(, *|$)// ; s/(, *|^)master(, *|$)// ; s/(^| *)tag: ([^ ]+?)(,|\n$)/$2\n/g; print' | sed '/^[ \t]*$/ d ; s/^ *//')
last_tags=""
for i in $pseudo_last_tags
do
if [[ $all_tags =~ $i ]] ; then last_tags=$last_tags" $i" ; fi
done
last_tags="$(echo $last_tags | sed 's/^ *//')"
##echo $last_tags
#for i in $last_tags
#do
# thebranch=$(git branch -a --contains $(git rev-list $i | head -n1) | tr -d '\n' | sed 's/ *\* */ /g ; s/ *-> */ /g')
# echo "$i $thebranch"
#done
#better: TODO: put tags found in a hash indexed by the branches, then display tags by branches
for i in $(git branch -a -vv | awk '{print $1}' | sed '/^ *\* *$/ d') ; do echo "`echo $i | sed 's:^remotes/:r/:'` `git describe --abbrev=0 --tags $i 2>/dev/null`" ; done
exit 0
## TODO : determine the branch of the tags...
## maybe only keep tags that affect the current branch
# take the first with numbers, or the first one:
version= #TODO
version=$(echo "$last_tags" | cut -d ' ' -f 1)
#by default:
if [[ $last_tags == "" ]]
then
version="0.1"
git tag $version
fi
# Rename current branch to "upstream"
git branch -m upstream
# Duplicate it to master (the debianized branch)
git checkout -b master
# Go to git repo root
old_wd=`pwd`
cd $root_repo_path
# Create the debian/ directory
dh_make -p eudev_$version --createorig
## change the -1 in -0 in the changelog, so that when we start working the first releasable version will be -1
git add debian
git commit -m "debianize"
git tag debian/$version