mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
Add git_unshallow and latest_commit_hash
This commit is contained in:
@@ -75,3 +75,17 @@ function prevent_sudo_or_root(){
|
||||
root) echo -e "${STY_RED}[$0]: This script is NOT to be executed with sudo or as root. Aborting...${STY_RESET}";exit 1;;
|
||||
esac
|
||||
}
|
||||
function git_unshallow(){
|
||||
# We need this function for latest_commit_hash to work properly
|
||||
if [[ -f "$(git rev-parse --git-dir)/shallow" ]]; then
|
||||
echo "Shallow clone detected. Unshallowing..."
|
||||
git fetch --unshallow
|
||||
fi
|
||||
}
|
||||
function latest_commit_hash(){
|
||||
local target_path="$1"
|
||||
if [[ ! -e "$target_path" ]]; then
|
||||
echo "[latest_commit_hash] '$target_path' does not exist. Aborting...";exit 1
|
||||
fi
|
||||
echo $(git log -1 --format="%H" -- "$target_path" 2>/dev/null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user