PRE_BUILD_AUTOMATION: added THISREPO placeholder

This commit is contained in:
XargonWan 2024-08-12 09:14:59 +09:00
parent 5654864317
commit 0be430f811
2 changed files with 23 additions and 3 deletions

View file

@ -51,7 +51,18 @@ get_current_branch() {
fi fi
} }
# Retrieve the repository URL
get_repo_url() {
local repo_url=$(git config --get remote.origin.url)
# Convert SSH URL to HTTPS if needed
if [[ "$repo_url" == git@* ]]; then
repo_url=$(echo "$repo_url" | sed -e 's|git@|https://|' -e 's|:|/|')
fi
echo "$repo_url"
}
current_branch=$(get_current_branch) current_branch=$(get_current_branch)
current_repo_url=$(get_repo_url)
echo "Manifest location: $rd_manifest" echo "Manifest location: $rd_manifest"
echo "Automation task list location: $automation_task_list" echo "Automation task list location: $automation_task_list"
@ -170,6 +181,13 @@ handle_url() {
/bin/sed -i 's^'"$placeholder"'^'"$calculated_url"'^g' "$rd_manifest" /bin/sed -i 's^'"$placeholder"'^'"$calculated_url"'^g' "$rd_manifest"
} }
# Handle the THISREPO placeholder
handle_thisrepo() {
local placeholder="$1"
echo "Replacing placeholder $placeholder with repository URL $current_repo_url"
/bin/sed -i 's^'"$placeholder"'^'"$current_repo_url"'^g' "$rd_manifest"
}
# Process the task list # Process the task list
while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do
if [[ ! "$action" == "#"* ]] && [[ -n "$action" ]]; then if [[ ! "$action" == "#"* ]] && [[ -n "$action" ]]; then
@ -184,6 +202,8 @@ while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do
"outside_env_var" ) handle_outside_env_var "$placeholder" "$url" ;; "outside_env_var" ) handle_outside_env_var "$placeholder" "$url" ;;
"custom_command" ) handle_custom_command "$url" ;; "custom_command" ) handle_custom_command "$url" ;;
"url" ) handle_url "$placeholder" "$url" ;; "url" ) handle_url "$placeholder" "$url" ;;
"THISREPO" ) handle_thisrepo "$placeholder" ;;
esac esac
fi fi
done < "$automation_task_list" done < "$automation_task_list"

View file

@ -90,7 +90,7 @@ modules:
echo "Version is $VERSION" echo "Version is $VERSION"
sources: sources:
- type: git - type: git
url: https://github.com/RetroDECK/RetroDECK.git url: THISREPO
branch: THISBRANCH branch: THISBRANCH
- name: xmlstarlet - name: xmlstarlet
@ -178,7 +178,7 @@ modules:
sha256: f5f359d6332861bd497570848fcb42520964a9e83d5e3abe397b6b6db9bcaaf4 sha256: f5f359d6332861bd497570848fcb42520964a9e83d5e3abe397b6b6db9bcaaf4
dest: fontconfig dest: fontconfig
- type: git - type: git
url: https://github.com/RetroDECK/RetroDECK.git url: THISREPO
branch: THISBRANCH branch: THISBRANCH
# RetroArch # RetroArch
@ -649,5 +649,5 @@ modules:
sources: sources:
- type: git - type: git
url: https://github.com/RetroDECK/RetroDECK.git url: THISREPO
branch: THISBRANCH branch: THISBRANCH