-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_nomerged_list
More file actions
executable file
·51 lines (40 loc) · 1.34 KB
/
export_nomerged_list
File metadata and controls
executable file
·51 lines (40 loc) · 1.34 KB
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
#!/bin/bash
#!/bin/bash
# Synopsis
# Tool to list all not merged remote branches of a Git repository which are not whitelisted
# Output is a comma separated value file (VCSV) containing the branch name, commit and author
# information. The CSV file is sorted and contains a header.
# Parameter
# 1st parameter: The whitelist must contain 1 line per branch to be whitelisted.
# 2nd parameter: Name of the file with the not merged branches.
whitelist=$1
nomergedlist=$2
rm -f "$nomergedlist"
echo "Branchname,Commit Date,Committer,Commiter Email,Author data,Author,Author Email" >> "$nomergedlist"
while read remote; do
found=false
while read white; do
if [[ "$remote" =~ "$white" ]]
then
found=true;
fi
done < "$whitelist"
if ! $found;
then
remote=${remote#origin/}
if [ "$remote" != "master" ]; # ignore master and release
then
echo checkout $remote
git checkout $remote
echo $remote,$(git log --date=short --pretty="%cd,%cn,%ce,%ad,%an,%ae" -1) >> "$nomergedlist"
fi
else
echo "Found '${remote#origin/}' in whitelist. Ignoring."
fi
done < <(git branch -r --no-merged | command grep -vE "^(\*|\s*master\s*$)")
# Sort by dates
tmpfile=$(mktemp)
sort --field-separator=',' --key=2 --key=5 --key=1 "$nomergedlist" > "$tmpfile"
mv "$tmpfile" "$nomergedlist"
# Clean up
rm -rf "$tmpfile"