-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetDebugInfo.sh
More file actions
73 lines (52 loc) · 2.42 KB
/
getDebugInfo.sh
File metadata and controls
73 lines (52 loc) · 2.42 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
m_files=( $(find ./${PRODUCT_NAME} -name '*.m') )
lines=0
ifs=0
unsign=0
for i in ${m_files[@]}; do
lines=$(( $lines + $(wc -l < $i) ))
ifs=$(( $ifs + $(sed -n -e '/^[ \t]*if[ \t]*(/p' $i | wc -l) ))
unsign=$(( $unsign + $(sed -n -e '/^[ \t]*\/\//p' $i | wc -l) ))
unsign=$(( $unsign + $(grep -c ^$ $i) ))
done
if_coef='<key>IfCoef</key><string>'$(bc <<<"scale=4;$ifs/($lines-$unsign)")'</string>'
commit=$(git log --pretty=format:'%H' -n 1)
commit_date='<key>CommitDate</key><string>'$(git log -n 1 --format='%cd')'</string>'
build_tags=( $(git tag | grep "$1\.*") )
from=$commit
to=$(git rev-list --max-parents=0 HEAD)
if [ ${#build_tags[@]} -gt 0 ]; then
from=$(git log ${build_tags[0]} -n 1 --format='%H')
fi
if [ ${#build_tags[@]} -gt 1 ]; then
to=$(git log ${build_tags[1]} -n 1 --format='%H')
fi
if [ $from = $to ]; then
notices[0]=$from
else
notices=( $(git log $from...$to --format='%H') )
if [ $to = $(git rev-list --max-parents=0 HEAD) ]; then
notices=(${notices[@]} $to)
fi
fi
notices_array='<key>Notices</key><array>'
for var in "${notices[@]}"
do
current_notice=$(git log --format=%B -n 1 ${var} | sed "s/\&/\&/;s/>/\>/;s/</\</;s/'/\'/g")
notices_array=$notices_array'<string>'$current_notice'</string>'
done
notices_array=$notices_array'</array>'
xml_head='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0">'
committer_name='<key>GitUserName</key><string>'$(git config user.name)'</string>'
committer_email='<key>GitUserEmail</key><string>'$(git config user.email)'</string>'
build_time='<key>BuildTime</key><string>'$(date +"%Y-%m-%d %H:%M:%S")'</string>'
version_num='<key>VersionNumber</key><string>'$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")'</string>'
diff=$(git status --porcelain)
if [ ${#diff} -gt 0 ]; then
isClean='<key>BranchStatus</key><string>Not clean</string>'
else
isClean='<key>BranchStatus</key><string>Clean</string>'
fi
configuration='<key>BuildConfiguration</key><string>'${CONFIGURATION}'</string>'
echo $xml_head'<dict><key>CommitHash</key><string>'$commit'</string>'$commit_date$committer_name$committer_email$build_time$version_num$isClean$configuration$if_coef$notices_array'</dict></plist>' | xmllint --format - >debugInfo.plist
cp debugInfo.plist "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/debugInfo.plist"