-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathgit_push.sh
More file actions
executable file
·98 lines (82 loc) · 2.49 KB
/
git_push.sh
File metadata and controls
executable file
·98 lines (82 loc) · 2.49 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
#!/usr/bin/env bash
repo="$HOME/workspace/my/studies"
cd "$repo" || exit
# 执行文档测试
printf "=== Start Doc Test ===\n"
test_path="$repo/code/my"
out=$(python code/scripts/doctest_modules_recur.py "$test_path")
if [[ $out != 0 ]]; then
echo "Not all file pass doctest($test_path)"
exit
else
echo "$out"
echo "All file passed doctest."
fi
echo
# 生成 README.md
printf "=== Start generating README.md ===\n"
out=$(python code/scripts/generate_readme_examples.py \
--repo_path "$repo" \
--code_path "$repo/code" \
--algo_path "$repo/algorithm" \
--module_path "$repo/code/my")
echo "$out"
if [[ $out = 'DIFF' ]]; then
git add "README.md" "$repo/code/README.md" "$repo/algorithm/*"
git commit -m '[U] Auto-README.md'
fi
echo
# 子仓库
prefix="algorithm"
name="algorithm"
echo "=== Start Push $name ==="
git subtree split --prefix=$prefix --branch $name --rejoin
git subtree push --prefix=$prefix $name master --squash
echo
# 主仓库
printf "=== Start Push Main Repo ===\n"
git push
echo
# 统计 commit 次数
#num_commits=$(git log | grep '^commit ' | awk '{print $1}' | uniq -c | awk '{print $1}')
#split_feq=20 # 每提交 20 次再 split 一次
#split_flag=$((num_commits % split_feq))
#prefix="code"
#name="my_lab"
#echo "=== Start Push $name ==="
#git subtree split --prefix=$prefix --branch $name --rejoin
#git subtree push --prefix=$prefix $name master --squash
#echo
#
#prefix="code/my"
#name="my"
#echo "=== Start Push $name ==="
#git subtree split --prefix=$prefix --branch $name --rejoin
#git subtree push --prefix=$prefix $name master --squash
#echo
#====================== history
# git subtree add --prefix=code/keras_demo/keras_model/bert_by_keras bert_by_keras master --squash
# git subtree add --prefix=code/keras_demo keras_demo master --squash
# 使用 submodule 代替 subtree
# git subtree push --prefix=code/keras_demo/keras_model/bert_by_keras bert_by_keras master
# git subtree push --prefix=code/keras_demo keras_demo master
# 获取仓库父目录
#pwd=$(pwd)
# 先更新子仓库
#printf "=== First: Update submodule ===\n"
# 1.
#sub_repo="bert_by_keras"
#echo "____ Start update $sub_repo"
#cd "$pwd/code/my_models/$sub_repo" || exit
#ret=$(git pull origin master)
#if [[ $ret =~ "Already up to date" ]]; then
# echo "$sub_repo is already up to date."
#else
# cd "$pwd" || exit
# git add "$pwd/code/my_models/$sub_repo"
# git commit -m "U $sub_repo"
#fi
# 更新父仓库
#cd "$pwd" || exit
#printf "\n=== Final: Push father repository ===\n"
#git push