-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.bash
More file actions
executable file
·113 lines (78 loc) · 3.67 KB
/
github.bash
File metadata and controls
executable file
·113 lines (78 loc) · 3.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Author: Darek L (aka dprojects)
# Version: 2022.11.25
# Latest version: https://github.com/dprojects/dev-tools
# ###################################################################################################################
# Globals
# ###################################################################################################################
NAME="`git config --global user.name`"
EMAIL="`git config --global user.email`"
if [[ -f "../${NAME}.token" ]];then
GITHUB_TOKEN=`cat "../${NAME}.token"`
fi
# ###################################################################################################################
# Info
# ###################################################################################################################
echo -e "******************************************************************************************************";
echo -e "*";
echo -e "* Current settings:";
echo -e "*";
printf "* %-25s : %-30s \n" "Name" "${NAME}"
printf "* %-25s : %-30s \n" "Token (GITHUB_TOKEN)" "${GITHUB_TOKEN}"
printf "* %-25s : %-30s \n" "E-mail" "${EMAIL}"
echo -e "*";
echo -e "* Usage:";
echo -e "*";
printf "* %-40s : %-30s \n" "Set active user" "bash `basename $0` --user [USER]";
printf "* %-40s : %-30s \n" "Create new repository and commit to it" "bash `basename $0` --init [URL]";
printf "* %-40s : %-30s \n" "Commit to current repository" "bash `basename $0` --update [MSG]";
printf "* %-40s : %-30s \n" "Check annoying typos" "bash `basename $0` --typos";
echo -e "*";
echo -e "******************************************************************************************************";
# ###################################################################################################################
# Set active user
# ###################################################################################################################
if [[ $1 == "--user" && $2 != "" ]];then
GITHUB_USER="$2"
git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_USER}@users.noreply.github.com"
echo -e "";
echo -e "New settings:";
echo -e "";
printf "%-20s : %-30s \n" "User name: " "`git config --global user.name`"
printf "%-20s : %-30s \n" "User email: " "`git config --global user.email`"
echo -e "";
fi
# ###################################################################################################################
# Create new repository and commit to it
# ###################################################################################################################
if [[ $1 == "--init" && $2 != "" ]];then
PROJECT="$2"
COMMIT_MSG="init";
git init;
git add .;
git commit -m "${COMMIT_MSG}";
git remote add origin "${PROJECT}";
git push -u origin master;
fi
# ###################################################################################################################
# Commit to current repository
# ###################################################################################################################
if [[ $1 == "--update" && $2 != "" ]];then
COMMIT_MSG="$2";
git init;
git add .;
git commit -m "${COMMIT_MSG}";
echo -e "All fine? Submit?: (y) or (n): \c"; read ANS;
if [ "${ANS}" == "y" ]; then
git push;
fi
fi
# ###################################################################################################################
# Check annoying typos
# ###################################################################################################################
if [[ $1 == "--typos" ]];then
codespell
fi
# ###################################################################################################################
echo -e "";