Skip to content

Instantly share code, notes, and snippets.

@soulflyman
Created February 15, 2017 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulflyman/1114c8c9872a9c91b05c2271cde7bb92 to your computer and use it in GitHub Desktop.
Save soulflyman/1114c8c9872a9c91b05c2271cde7bb92 to your computer and use it in GitHub Desktop.
Create update archives, with all changed files, from a git repostiry
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo -e "usage: buil <fromTAG> <toTAG> <outputFOLDER>\n";
echo -e "Creates a ZIP file with all files that where changed between the fromTAG and the toTag."
echo -e "Parameters:\n";
echo -e "\t<fromTag>\t the tag FROM which you want to update";
echo -e "\t<toTag>\t\t the tag TO which you want to update";
echo -e "\t<outputFOLDER>\t the folder where the generated zip archive will be saved\n";
echo -e "If you leave the outputFOLDER parameter empty, no archive will be created";
echo -e "but list with changed files is printed.\n\n";
echo -e "Note: fromTAG and toTAG can also be a branch or a commit.\n";
echo -e "ATTENTION: The script does not check if the target file exists.\nIf it exists, it will be overwritten.";
exit;
fi
changedFiles=$(git diff --name-only ${1} ${2});
if [ -n "$1" ] && [ -n "$2" ] && [ -z "$3" ]; then
echo $changedFiles;
fi
if [ -n "$1" ] && [ -n "$2" ] && [ -n "$3" ]; then
repoName=$(basename `git rev-parse --show-toplevel`);
outputFileName="${3}/${repoName}_from_${1}_to_${2}_UPDATE.zip";
git archive -o ${outputFileName} ${2} ${changedFiles};
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment