File tree Expand file tree Collapse file tree 6 files changed +558
-10
lines changed
Expand file tree Collapse file tree 6 files changed +558
-10
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # set -e
4+
5+ source " .pre-commit.state"
6+
7+ for item in " ${! CHANGED[@]} "
8+ do
9+ mv " ${CHANGED["${item}"]} " " ${item} "
10+ done
11+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+
6+ echo " " > .pre-commit.state
7+ echo " " > .pre-commit.state.log
8+
9+ BRANCH=$( git rev-parse --abbrev-ref HEAD)
10+ declare -A CHANGED=()
11+
12+ for item in " $( git diff --name-only --cached) "
13+ do
14+ echo " item: ${item} " >&2
15+ found=0
16+ if [[ ${item} =~ \. md$ ]] || [ " ${item} " == " install.deb.sh" ]
17+ then
18+ echo " CHANGED: ${item} " >&2
19+ CHANGED[" ${item} " ]=" ${item} .$( uuidgen) "
20+ cp -a " ${item} " " ${CHANGED["${item}"]} "
21+ cp -a " ${item} " " ${item} .template"
22+ git add " ${item} .template"
23+ # change file as needed
24+ sed -i " s:@branch@:${BRANCH} :g" " ${item} "
25+ diff " ${item} " " ${CHANGED["${item}"]} " >> .pre-commit.state.log || true
26+ git status >> .pre-commit.state.log || true
27+ git add " ${item} " || true
28+ git status >> .pre-commit.state.log || true
29+ fi
30+ done
31+
32+ declare -p CHANGED >> .pre-commit.state
33+
34+ # git branch
35+ # pwd
36+ # env | grep -i git
Original file line number Diff line number Diff line change @@ -102,14 +102,14 @@ Reading state information... Done
102102
103103So the quickest way is:
104104```
105- curl -s https://raw.githubusercontent.com/hastmu/apt-proxy-detect/refs/heads/release/v1.0.0/ install.deb.sh | sudo BRANCH=release/v1.0.0 bash
105+ curl -s https://raw.githubusercontent.com/hastmu/apt-proxy-detect/refs/heads/@branch@/ install.deb.sh | sudo BRANCH=@branch@ bash
106106```
107107
108108looks like
109109
110110```
111- dev@dev~#> curl -s https://raw.githubusercontent.com/hastmu/apt-proxy-detect/refs/heads/release/v1.0.0/ install.deb.sh | sudo BRANCH=release/v1.0.0 bash
112- - BRANCH [release/v1.0.0 ]
111+ dev@dev~#> curl -s https://raw.githubusercontent.com/hastmu/apt-proxy-detect/refs/heads/@branch@/ install.deb.sh | sudo BRANCH=@branch@ bash
112+ - BRANCH [@branch@ ]
113113- downloading ... ok.
114114dpkg-deb: building package 'apt-proxy-detect' in 'apt-proxy-detect_1.0.0_1730626377.deb'.
115115Reading package lists... Done
You can’t perform that action at this time.
0 commit comments