Skip to content

Instantly share code, notes, and snippets.

@andreineculau
Last active June 29, 2020 11:55
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 andreineculau/a267bc5e2f64487f5812d24a56aa2283 to your computer and use it in GitHub Desktop.
Save andreineculau/a267bc5e2f64487f5812d24a56aa2283 to your computer and use it in GitHub Desktop.
git-filter for codeship jet command (doesn't work because 'jet encrypt' is not deterministic)
# NOTE .git/config not .git-config, but github gist doesn't allow slash
[filter "jet"]
clean = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-clean %f
smudge = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-smudge
required = true
[diff "jet"]
textconv = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-textconv
cachetextconv = true
binary = true
/codeship-env/*.encrypted filter=jet diff=jet
#!/usr/bin/env bash
filename=$1
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp)
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp)
trap 'rm -f "$tempfile" "$tempfile2"' EXIT
tee "$tempfile" &>/dev/null
if [[ -s $filename ]]; then
read -n 11 firstbytes <"$tempfile"
if [[ $firstbytes == "codeship:v2" ]]; then
cat "$tempfile"
elif [[ ! -e codeship.aes ]]; then
cat "$tempfile"
else
jet encrypt "$filename" "$tempfile2"
cat "$tempfile2"
fi
fi
#!/usr/bin/env bash
filename=$1
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp)
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp)
trap 'rm -f "$tempfile" "$tempfile2"' EXIT
tee "$tempfile" &>/dev/null
read -n 11 firstbytes <"$tempfile"
if [[ $firstbytes != "codeship:v2" ]]; then
cat "$tempfile"
elif [[ ! -e codeship.aes ]]; then
cat "$tempfile"
else
jet decrypt "$tempfile" "$tempfile2"
cat "$tempfile2"
fi
#!/usr/bin/env bash
filename=$1
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp)
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp)
trap 'rm -f "$tempfile" "$tempfile2"' EXIT
cat "$filename" | tee "$tempfile" &>/dev/null
if [[ -s $filename ]]; then
if [[ ! -e codeship.aes ]]; then
cat "$tempfile"
else
jet decrypt "$tempfile" "$tempfile2"
cat "$tempfile2"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment