This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
forked from polydawn/mdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-devlink.sh
executable file
·165 lines (129 loc) · 2.49 KB
/
test-devlink.sh
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
mkdir arena
cd arena
rm -rf devlink
mkdir devlink
cd devlink
function explain {
cat <(echo -ne "\E[1;32m") - <(echo -ne "\E[0m")
}
explain <<-'EOF'
#
# We're going to create a project, add a dependency...
# And then try to replace it with a symlink to nonsense, without disrupting git status.
#
# I'm not saying this is a *good* idea, but it might be an interesting way to have a "dev" mode.
#
EOF
set -v
(
git init project
cd project
touch somescript.sh
git add .
git commit -m "a demo project"
mdm add http://mdm-releases.com/junit/junit-releases.git --version 4.11.mvn
mdm status
)
set +v
echo
echo
explain <<-'EOF'
#
# `git status` should be clear, and we should see a library there.
#
EOF
set -v
(
cd project
git status
ls -l
ls -l lib/junit/
)
set +v
echo
echo
explain <<-'EOF'
#
# Now suppose we have some development-mode resources lying elsewhere.
#
# What if we want to refer to those instead, and we don't want to publish releases?
#
# (Obviously, this means we'd be putting our workspace in a state that
# *no one else can reproduce*.
# ...But let's suppose we're fine with that, for the moment.)
#
EOF
set -v
(
mkdir dev-junit
touch dev-junit/junit.jar # just pretend
)
set +v
echo
echo
explain <<-'EOF'
#
# We can just overwrite the mdm dependency location with a symlink.
#
# This will work (sorta), but:
# - `git status` will report a typechange
# - `mdm update` is honestly a little confused
#
EOF
set -v
(
cd project
rm -rf lib/junit
ln -s ../../dev-junit lib/junit
git status
ls -l lib/
ls -l lib/junit/
mdm status
)
set +v
echo
echo
explain <<-'EOF'
#
# What if we just ignore it?
#
# Plain old '.gitignore' patterns won't work -- the lib/junit path is already tracked.
#
# Git has another way: we can just ask git to always pretend this path is unchanged.
#
EOF
set -v
(
cd project
git update-index --assume-unchanged lib/junit
git status
ls -l lib/
mdm status
)
set +v
echo
echo
explain <<-'EOF'
#
# Going back to "prod" mode, with the dependency as linked by mdm, is easy:
# - remove the symlink
# - `mdm update` as usual
#
# Note that this *is* a little weird. The assume-unchanged feature interferes very brutally:
# Even completely absent files aren't marked as deleted or missing.
# It's really up to you to remember that you may be in a state that's out of sync
# with what you and others are pushing and pull.
#
EOF
set -v
(
cd project
rm lib/junit
mdm update
ls -l lib/junit
mdm status
)
set +v
echo
echo