| Hash | Commit message | Author | Date | Files | + | - |
1 | commit abb4fdff054561f0c0357e4f1e35299042d610a7 |
2 | Author: Connor Etherington <[email protected]> |
3 | Date: Tue Sep 20 00:53:52 2022 +0200 |
4 | |
5 | Auto-Commit Update 20.09.2022 - 00:53:52 |
6 | --- |
7 | usr/bin/repoup | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
8 | 1 file changed, 112 insertions(+) |
9 | |
10 | diff --git a/usr/bin/repoup b/usr/bin/repoup |
11 | new file mode 100755 |
12 | index 0000000..e03f4fa |
13 | --- /dev/null |
14 | +++ b/usr/bin/repoup |
15 | @@ -0,0 +1,112 @@ |
16 | +#!/usr/bin/env bash |
17 | + |
18 | +# Debugging: |
19 | +#trap 'lastCommand=$currentCommand; currentCommand=$BASH_COMMAND' DEBUG |
20 | +#trap 'echo -e "\n\e[1;31m [-]\e[0m\e[1;33m Last Successful Command:\e[0m $lastCommand\e[0m\ |
21 | +# \n\e[1;31m [-]\e[0m\e[1;33m Failed Command:\e[0m $BASH_COMMAND \e[0m\n"' EXIT QUIT STOP ERR |
22 | + |
23 | + |
24 | +ADD(){ |
25 | + for x in ${@}; do |
26 | + cp -vfr ${PWDIR}/${x} ${REPOPATH} >/dev/null 2>&1 ||[41m |
27 | + mkdir -p ${REPOPATH} && cp -vfr ${PWDIR}/${x} ${REPOPATH} >/dev/null 2>&1 && |
28 | + echo -e "\e[1;32m\n[+] \e[0m\e[1;33m${x}\e[0m \e[1;32madded to \e[36m$(basename ${REPO})\e[32m on \e[36m${BRANCH:-master}\e[0m\n" |
29 | + done |
30 | +} |
31 | + |
32 | +PUSH(){ |
33 | + for x in ${BRANCHES[@]}; do |
34 | + cd $REPO |
35 | + git checkout $x |
36 | + git add . |
37 | + git commit -m "$REPO update" |
38 | + git push origin ${x:-master} |
39 | + done |
40 | +} |
41 | + |
42 | +PUSHTOBRANCH(){ |
43 | + BRANCH=${1:-master} |
44 | + cd $REPO ; |
45 | + git checkout $1 |
46 | + git add . |
47 | + git commit -m "$REPO update" |
48 | + git push origin $1 |
49 | +} |
50 | + |
51 | +ADDTOALL(){ |
52 | + for x in ${BRANCHES[@]}; do |
53 | + BRANCH=${x:-master} |
54 | + cd $REPO |
55 | + git checkout $x |
56 | + ADD ${*} |
57 | + git add . |
58 | + git commit -m "$REPO update, added ${*}" |
59 | + done |
60 | +} |
61 | + |
62 | +ADDTOBRANCH(){ |
63 | + BRANCH=${1:-master} |
64 | + cd $REPO |
65 | + git checkout $1 |
66 | + ADD ${@:2} |
67 | + git add . |
68 | + git commit -m "$REPO update, added ${@:2}" |
69 | +} |
70 | + |
71 | +USAGE(){ |
72 | +echo -e "\n\n \e[1;32mUsage: \e[0;33m`echo $0|sed 's|./||'` \e[0;35m<FLAG> |
73 | + |
74 | + \e[0;35m-b \e[0;36m <BRANCH> <FILES> : \e[0;37mAdd file(s) to specified branch |
75 | + \e[0;35m-a \e[0;36m <BRANCH> <FILES> : \e[0;37mAdd file(s) to all branches |
76 | + \e[0;35m-pb \e[0;36m<BRANCH> : \e[0;37mPush to specified branch |
77 | + \e[0;35m-pa \e[0;36m<BRANCH> : \e[0;37mPush to all branches |
78 | + \e[0;35m-h \e[0;36m<REPO> : \e[0;37mDisplay this help message |
79 | + \e[0;35m-r \e[0;36m<REPO> : \e[0;37mSpecify the repo (this flag must be first, followed by the repo path, then additional options) |
80 | + |
81 | +[41m |
82 | + \e[0;37mBy default, files are added to the current branch. |
83 | + |
84 | + \e[1;33mExamples : \e[0;37m`echo $0|sed 's|./||'` -r /path/to/repo -b master <file1> <file2> <file3> |
85 | + : \e[0;37m`echo $0|sed 's|./||'` -r /path/to/repo -a <file1> <file2> <file3> |
86 | +[41m |
87 | +[41m |
88 | + \e[1mA Default Repo to which files are added can be set in the repouprc file, located in ${XDG_CONFIG_HOME:-$HOME/.config}/repoup/repouprc |
89 | + |
90 | + \e[0;33mNOTE: \e[1;34mUnless a default repo is set, the repo must be specified with the \e[0;35m-r \e[0;36m<REPO> \e[0;34mflag\e[0m\n" |
91 | +} |
92 | + |
93 | +MAIN(){ |
94 | + |
95 | + REPOPATH="${REPO}/`pwd | sed -e "s|$HOME/||g"`" |
96 | + BRANCHES=( $(cd $REPO; echo `git branch|sed 's|\* ||'`) ) |
97 | + |
98 | + case ${1} in |
99 | + -b|--branch) ADDTOBRANCH ${2} ${@:3} ;; |
100 | + -a|--add) ADDTOALL ${@:2} ;; |
101 | + -pb|--push) PUSHTOBRANCH ${2} ;; |
102 | + -p|-pa|--pushall) PUSH ;; |
103 | + -r) [[ -n ${2} ]] && REPO=$(realpath ${2}) ; MAIN ${@:3} ;; |
104 | + -h|help) USAGE ;; |
105 | + '') echo -e "\n\e[1;31m [-]\e[0m\e[1;33m No flags specified, use \e[0;35m-h \e[0;33mfor help\e[0m\n" ;; |
106 | + *) ADD ${@} ;; |
107 | + esac |
108 | +} |
109 | + |
110 | + |
111 | + |
112 | + # Script Start: |
113 | +# --- |
114 | + |
115 | +set -e |
116 | + |
117 | +PWDIR=`pwd` |
118 | + |
119 | +source ${XDG_CONFIG_HOME:-$HOME/.config}/repoup/repouprc >/dev/null 2>&1 || true |
120 | + |
121 | +[[ -n ${DEFAULT_REPO} ]] && REPO=${DEFAULT_REPO} |
122 | + |
123 | + |
124 | +MAIN ${@} || USAGE |
125 | + |
126 | +# --- |
127 | + |