-
-
Save fatso83/ce2d30a9de2d8fca994e8b6786b48d9f to your computer and use it in GitHub Desktop.
Sinon Doc Editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage example: ./edit_sinon_docs.sh stubs 4.1.1 | |
# Will open stubs.md from 4.1.1 for editing and propagate the changes to later versions. | |
# Make sure you have SINON_HOME pointing to the repository root. | |
# You'll need git and the npm "semver" package installed (npm i -g semver) | |
cd $SINON_HOME/docs | |
FILENAME=$1.md | |
FROM_VERSION=$2 | |
EDITOR=`git config core.editor` | |
EDITOR=${EDITOR:-vim} | |
LATER_VERSIONS=($(ls -C _releases/*.md | xargs semver -c -r ">$FROM_VERSION")) | |
# Make a temp copy of the originals so that they can be used as the common parent in the 3-way merge | |
cp -r _releases .tmp_releases | |
$EDITOR _releases/v$FROM_VERSION/$FILENAME | |
prev=$FROM_VERSION | |
for ver in "${LATER_VERSIONS[@]}" | |
do | |
if ! git merge-file _releases/v$ver/$FILENAME .tmp_releases/v$prev/$FILENAME _releases/v$prev/$FILENAME ; then | |
$EDITOR _releases/v$ver/$FILENAME | |
fi | |
prev=$ver | |
done | |
git merge-file release-source/release/$FILENAME .tmp_releases/v$prev/$FILENAME _releases/v$prev/$FILENAME | |
rm -rf .tmp_releases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment