-
Notifications
You must be signed in to change notification settings - Fork 3
/
update-node-submodule.sh
executable file
·54 lines (43 loc) · 1.72 KB
/
update-node-submodule.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
#!/usr/bin/env sh
set -o errexit
set -o nounset
cd node
git fetch
MOST_RECENT_VERSION=${1:-$(git tag | sort -V | tail -n 1 )}
CURRENT_VERSION=$(git describe --tags HEAD)
if [ "$MOST_RECENT_VERSION" = "$CURRENT_VERSION" ]; then
echo "$CURRENT_VERSION is up to date, nothing to do"
exit 0
fi
CHANGED_FILES=$(git diff --name-only "$CURRENT_VERSION".."$MOST_RECENT_VERSION" src/node_api.h src/js_native_api.h src/js_native_api_types.h src/node_api_types.h)
if [ -z "$CHANGED_FILES" ]; then
echo "Relevant files did not change between $CURRENT_VERSION..$MOST_RECENT_VERSION"
exit 0
else
CHANGELOG=$(mktemp)
echo "# Node ${MOST_RECENT_VERSION}\n" >> $CHANGELOG
echo "affected files:" >> $CHANGELOG
for i in $CHANGED_FILES; do
echo "* [$i](https://github.com/nodejs/node/blob/$MOST_RECENT_VERSION/$i)" >> $CHANGELOG
done
echo "\nupstream changelog:" >> $CHANGELOG
# get a list of (space-separated) commit-ids we can easily loop over
for i in $(git log --format='%H' "$CURRENT_VERSION".."$MOST_RECENT_VERSION" src/node_api.h src/js_native_api.h src/js_native_api_types.h src/node_api_types.h); do
# now get the actual text of the commit (which contains multiple spaces)
echo "* $(git log -1 --format='[%h](https://github.com/nodejs/node/commit/%H) %s' $i)" >> $CHANGELOG
done
echo "" >> $CHANGELOG
fi
# for dry run mode:
# cat $CHANGELOG
# exit 0;
git checkout "$MOST_RECENT_VERSION"
if ! grep "NAPI_VERSION 8" src/node_version.h; then
echo "Detected new NAPI_VERSION. Refusing to auto-update. Please add feature-flag etc."
exit 1
fi
# back to src-root
cd ..
cat CHANGELOG.md >> $CHANGELOG
cat $CHANGELOG > CHANGELOG.md
git commit -m ":arrow_up: update node $CURRENT_VERSION -> $MOST_RECENT_VERSION" node CHANGELOG.md