-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogs2git
executable file
·78 lines (60 loc) · 1.78 KB
/
blogs2git
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
74
75
76
77
78
#!/bin/env zsh
# Version 3
# Dependencies
# - Git
# - zsh
# - xclip
# Changelog
# - 2018-01-29
# * Added GITHUB_URL
# * Check if there are any log files in the mock dir, if not, exit
# - 2018-01-16
# * Check if rpms are present, if so, delete them
# - 2018-01-14
# * Delete rpms if present before pushing to git
# * Add a little bit of color...
function include () {
# Edit this path to reflect your installation
local inc_file
inc_file=${HOME}/bin/include/${1}.inc
if [[ ! -f ${inc_file} ]]; then
local inc_opt
inc_opt=$( echo ${1} | cut -d\/ -f2 )
echo "Supplied option \"${inc_opt}\" is not valid."
else
builtin source ${inc_file} ${2}
fi
}
include common/slash_to_array
include common/colors
GIT_SRC=${HOME}/rpmbuild/mageia-mock-build-logs
GITHUB_URL="https://github.com/kekePower/mmbl"
PROJ_DIR=$(pwd)
slash_to_array ${PROJ_DIR}
PROJ_NAME=${sta[-1]}
YEAR=$(date +%Y)
MONTH=$(date +%m)
TIMESTAMP=$(date +%d-%H%M%S)
DIR_STRUCT=${GIT_SRC}/${PROJ_NAME}/${YEAR}/${MONTH}/${TIMESTAMP}
if [[ ! -d ${PROJ_DIR}/mock ]]; then
echo "${red}Are you sure you're in the right directory?${END}"
echo ${PROJ_DIR}
exit
fi
if [[ ! -a ${PROJ_DIR}/mock/build.log ]]; then
echo "${red}No logs found. Exiting."
exit
fi
if [[ ! -d ${DIR_STRUCT} ]]; then
echo "${white}-${green}>${END} ${blue}Creating directory structure for ${PROJ_NAME}${END}"
echo "${white}-${green}>${END} ${green}${DIR_STRUCT}${END}"
mkdir -p ${DIR_STRUCT}
fi
cp -a mock ${DIR_STRUCT}/
find ${DIR_STRUCT} -name *.rpm -delete
builtin cd ${GIT_SRC}
git pull
git add .
git commit -m "Build logs for ${PROJ_NAME} on ${YEAR}${MONTH}${TIMESTAMP}"
git push
echo "${GITHUB_URL}/tree/master/${PROJ_NAME}/${YEAR}/${MONTH}/${TIMESTAMP}/mock" | tee /dev/tty | xclip -selection clipboard