Skip to content

Instantly share code, notes, and snippets.

@luzpaz
Last active August 8, 2022 19:11
Show Gist options
  • Save luzpaz/d0d3d2f640f4b20a8ad7b1abe427fc9b to your computer and use it in GitHub Desktop.
Save luzpaz/d0d3d2f640f4b20a8ad7b1abe427fc9b to your computer and use it in GitHub Desktop.
List FreeCAD commits pending the local copy you're running
#!/bin/bash
# This script will ascertain what hash number (derived from revision number) your current
# local copy of FreeCAD is based on. Then it lists the commits that haven't made it in to
# said local copy.
git fetch --all # Make sure up-to-date
head=$(git rev-list --count HEAD)
echo -e "\n"
echo -e "Upstream: $head"
# Below are optional ways to get the local hash version of FreeCAD
# TODO: fix out if this works for macOS and Windows
#local=$(freecad.cmd --version | cut -d " " -f4)
local=$(freecad.cmd -c "import FreeCAD;print(f\"{FreeCAD.Version()[6]}\")" | sed 1d -)
#local=$(./FreeCAD.AppImage -c "import FreeCAD;print(f\"{FreeCAD.Version()[6]}\")")
echo -e "Local: $local"
diff=$(($head-$local)) # subtract to get the difference
echo -e "Difference: $diff"
commit_hash=$(git rev-parse --short HEAD~$diff)
echo -e "The hash for FreeCAD revision $local is $commit_hash"
echo -e "\nListed below are commits that aren't in your version of FreeCAD"
echo -e "---------------------------------------------------------------"
# List commits not in local copy of FreeCAD
git log --oneline --ancestry-path ${commit_hash}..HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment