Commit 2c1c8817 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Creation and usage of patch file for Word document generation

parent 95eb4975
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
#!/bin/bash

DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.1.0
DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.3.0

echo "\n------ Checking for docker image --------"
docker pull "$DOCKER_IMAGE"
@@ -10,15 +10,28 @@ rm **/*.docx

echo "------ Parsing repo URL --------"

HOST_URL=$(echo $1 | cut -d'/' -f 1-3)
HOST_URL=$(echo $1 | cut -d'/' -f 1-4)
PROJECT_NAME=$(echo $1 | cut -d'/' -f 5- | cut -d'.' -f 1)
echo "HOST URL:" $HOST_URL
echo "PROJECT NAME:" $PROJECT_NAME
echo "PROJECT ID:" $2
echo "MERGE IID:" $3

#echo "\n------ Generating patch file --------"
#Getting commit ids for the merge request
#mergeUrl=$HOST_URL/api/v4/projects/$2/merge_requests/$3
#start_sha="$(curl $mergeUrl | grep -Eo \"start_sha\":\"[^\:,]*\" | cut -d':' -f 2 | cut -d'"' -f 2)"
#head_sha="$(curl $mergeUrl | grep -Eo \"head_sha\":\"[^\:,]*\" | cut -d':' -f 2 | cut -d'"' -f 2)"

#Generate patch file
#echo "git diff -p $start_sha $head_sha"
#git diff -p $start_sha $head_sha > merge_patch.patch

echo "\n------ Generating change marks --------"
docker container run --rm -v $(pwd):/tmp/ "$DOCKER_IMAGE" forgelib-changedocs -vv --combine --outPath=/tmp/docs --startdelimiter "/tmp/$4" --enddelimiter "/tmp/$5" "$HOST_URL" "$2" "$PROJECT_NAME" "$3"
#Using merge ID to get the diff
docker container run --rm -v $(pwd):/tmp/ "$DOCKER_IMAGE" forgelib-changedocs -vv --combine --outPath=/tmp/docs --startdelimiter "/tmp/$4" --enddelimiter "/tmp/$5" "$HOST_URL" "$2" "$3"
#Using the generated patch file from above (this approach eliminates the issue of diff limit
#docker container run --rm -v $(pwd):/tmp/ "$DOCKER_IMAGE" forgelib-changedocs -vv --combine --outPath=/tmp/docs --patchfile "merge_patch.patch" --startdelimiter "/tmp/$4" --enddelimiter "/tmp/$5" "$HOST_URL" "$2" "$PROJECT_NAME" "$3"

exit 0