This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
git-faker
112 lines (86 loc) · 2.94 KB
/
git-faker
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
#!/usr/bin/env sh
VERSION="0.2.0"
version() {
printf "git-faker version %s\n" "$VERSION"
}
# Helpers.
current_year() {
date +"%Y"
}
last_year() {
year=$(current_year)
echo $(( ${year#0} -1 ))
}
current_branch() {
basename "$(git symbolic-ref HEAD)"
}
faker() {
rm -rf .git-faker
mkdir .git-faker
if [ -z "$1" ]; then
branch="$(current_branch)"
else
branch="$1"
fi
case "$2" in
objc)
extension="m"
code="#import <UIKit/UIKit.h> @interface NSFaker () @end @implementation NSFaker - (instancetype)init { self = [super init]; if (self) {self.title = "faker";} return self; } @end " ;;
js)
extension="js"
code="var express = require('express'); console.log(express);" ;;
java)
extension="java"
code="public class IntListVer1 {private static final int DEFAULT_CAP = 10;private int[] iValues;private int iSize;public IntListVer1(){this(DEFAULT_CAP);}}" ;;
c)
extension="c"
code="#include <stdio.h> int main(){int c = 0;char ch, s[1000];gets(s);while (s[c] != '\0') {ch = s[c];if (ch >= 'A' && ch <= 'Z'){s[c] = s[c] + 32;}}return 0;}" ;;
*)
extension=""
code="default" ;;
esac
git checkout $branch >/dev/null
months=( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )
for month in ${months[@]}; do
for day in {1..31}; do
ranH=$RANDOM
ranS=$RANDOM
ranM=$RANDOM
hour=$(( ranH %= 23 ))
min=$(( ranM %= 59 ))
sec=$(( ranS %= 59 ))
echo "$code" > ".git-faker/$(current_year).$month.$day.$extension"
git add -A >/dev/null
GIT_AUTHOR_DATE="$month $day $hour:$min:$sec $(current_year) -0000" GIT_COMMITTER_DATE="$month $day $hour:$min:$sec $(current_year) -0000" git commit -m "I'm working hard.." >/dev/null
echo "$code" > ".git-faker/$(last_year).$month.$day.$extension"
git add -A >/dev/null
GIT_AUTHOR_DATE="$month $day $hour:$sec:$min $(last_year) -0000" GIT_COMMITTER_DATE="$month $day $hour:$sec:$min $(last_year) -0000" git commit -m "I'm hustlin" >/dev/null
done
done
printf "Great!\nYou should push to the GitHub!\nNow, you are the best commiter in the planet.\n"
}
display_help() {
cat <<-EOF
usage:
git faker Execute git faker at current branch
commands:
git faker <branch> Execute git faker with <branch> for commit
options:
-V, --version Output current version of git-faker
-h, --help Display this help information
--objc Set the language: Objective-C
--java Set the language: Java
--js Set the language: Javascript
--c Set the language: C
EOF
exit 0
}
case $1 in
-V|--version) version; exit 0 ;;
-h|--help) display_help; exit 0 ;;
--objc) faker "$(current_branch)" "objc"; exit 0 ;;
--java) faker "$(current_branch)" "java"; exit 0 ;;
--js) faker "$(current_branch)" "js"; exit 0 ;;
--c) faker "$(current_branch)" "c"; exit 0 ;;
esac
faker "$@"