Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions services/cloud-agent-next/scripts/kilo-git-credential
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,47 @@ done

[ "$protocol" = https ] || exit 0

session_home="${SESSION_HOME:-${HOME:-}}"
if [ -n "$session_home" ]; then
credential_file="$session_home/.local/share/kilo/cloud-agent/git-credentials"
if [ -f "$credential_file" ]; then
stored_protocol=
stored_host=
stored_username=
stored_password=
stored_host_matches=
stored_malformed=
stored_field_count=0

while IFS= read -r line || [ -n "$line" ]; do
stored_field_count=$((stored_field_count + 1))
case "$line" in
protocol=*) stored_protocol="${line#protocol=}" ;;
host=*)
stored_host="${line#host=}"
if [ "$stored_host" = "$host" ]; then
stored_host_matches=1
fi
;;
username=*) stored_username="${line#username=}" ;;
password=*) stored_password="${line#password=}" ;;
*) stored_malformed=1 ;;
esac
done < "$credential_file"

if [ -n "$stored_host_matches" ]; then
[ "$stored_host" = "$host" ] || exit 0
[ "$stored_field_count" -eq 4 ] || exit 0
[ -z "$stored_malformed" ] || exit 0
[ "$stored_protocol" = "$protocol" ] || exit 0
[ -n "$stored_username" ] || exit 0
[ -n "$stored_password" ] || exit 0
printf 'username=%s\npassword=%s\n' "$stored_username" "$stored_password"
exit 0
fi
fi
fi

username=
password=

Expand Down
Loading