11#! /bin/bash
2- # >testFile.txt
32# # Reset Manifest
43cp ./.ci/templates/manifest.tpl.xml src/manifest.xml
4+
5+ # # Store branch name for release
6+ echo " $2 " > ./.ci/.branch
7+
8+ # # Declare variables
9+ # ## Create xml schema variables
510endOfLine=" </path>\n"
11+
12+ # ## Create regex strings to test with
613srcRegex=' src\/.*'
714attributesRegex=' .*\.attributes.*'
815fileRegex=' src\/FileCabinet\/SuiteScripts.*'
916objectRegex=' src\/Objects\/.*'
1017objectScriptPathRegex=' .*scriptfile.*'
18+
19+ # ## Output strings for File and Object lines
20+ # ### Add more here if using other branches of deploy.xml schema
1121FILELINE=
1222OBJECTLINE=
23+ # # Read git log for files impacted since origin headbranch -- reverts are also in the log
1324while read line; do
14- # We only want to update src files in deployment
25+ # ## We only want to update src files in deployment
1526 if [[ " $line " =~ $srcRegex ]]; then
16- # Setup what the new line will look like
27+ # ## Test if file exists, if not we can skip it and import as dependency later
28+ if ! test -f " $line " ; then
29+ continue
30+ fi
1731
32+ # ## Setup what the new line will look like
1833 newLine=$( echo " $line " | sed " s/src\//\t<path>~\//" ) " $endOfLine "
19- # Is a src file
20- # Separate Files & Objects to build deploy.xml
21- # echo "$line"
34+
35+ # ## Skip duplicates -- lines which are already prepped to go in to deploy.xml
36+ if [[ $OBJECTLINE == * " $newLine " * || $FILELINE == * " $newLine " * ]]; then
37+ continue
38+ fi
39+
40+ # ## Separate Files & Objects to build deploy.xml
2241 if [[ " $line " =~ $fileRegex ]]; then
2342 if [[ " $line " =~ $attributesRegex ]]; then
2443 continue
25- elif ! test -f " $line " ; then
26- continue
2744 fi
28- # echo "file regex match"
29- # Is a file update
45+ # ### Is a file update
3046 FILELINE+=" \t${newLine} "
31- # echo $FILELINE
3247 elif [[ " $line " =~ $objectRegex ]]; then
33- # Test line to see if the object needs a file path added
48+ # ## Test line to see if the object needs a file path dependency added
3449 while read OBJLINE; do
3550 if [[ " $OBJLINE " =~ $objectScriptPathRegex ]]; then
36- # regexStr=".*${OBJLINE}.*"
37- # echo $OBJLINE
51+ # ### Modify line to deploy.xml schema
3852 SCRIPTPATH=$( echo " $OBJLINE " | sed " s/<scriptfile>\[/\/src/" )
3953 SCRIPTPATH=$( echo " ${SCRIPTPATH} " | sed " s/\]<\/scriptfile>//" )
4054 depLine=$( echo " ${SCRIPTPATH} " | sed " s/\/src\//\t<path>~\/FileCabinet\//" ) " $endOfLine "
4155 CLEANPATH=$( echo " $SCRIPTPATH " | sed " s/src\///" )
4256 regexLineStr=" .*$CLEANPATH "
57+
58+ # ### Check if dependency file is already in file paths list
4359 if [[ " $FILELINE " =~ $regexLineStr ]]; then
4460 continue
4561 fi
62+
63+ # #### Add to dependency to file list
4664 FILELINE+=" \t${depLine} "
4765 fi
4866 done < <( cat " ./${line} " )
49- # echo "object regex match"
50- # Is an object file update
67+
68+ # ### Is an object file update
5169 OBJECTLINE+=" \t${newLine} "
52- # echo $OBJECTLINE
5370 fi
5471 fi
72+ # ## Clear line variable
5573 line=" "
56- done < <( git diff origin/$1 $2 --name-only)
74+ done < <( git log --oneline --stat origin/$1 .. $2 --name-only)
5775
76+ # # Generate deploy.xml file
77+ # ## Define output string variable
5878OUTPUTLINES=" "
79+
80+ # ## If file path entries is > 0 add files to deploy.xml
5981if [[ $FILELINE ]]; then
6082 OUTPUTLINES=" <files>\n${FILELINE} \t</files>"
6183fi
84+
85+ # ## If object path entries is > 0 add objects to deploy.xml
6286if [[ $OBJECTLINE ]]; then
6387 OUTPUTLINES=" ${OUTPUTLINES} \n\t<objects>\n${OBJECTLINE} \t</objects>"
6488fi
89+
90+ # ## Print output to custom updated deploy.xml
91+ # shellcheck disable=SC2059
6592printf " <deploy>
6693 <configuration>
6794 <path>~/AccountConfiguration/*</path>
@@ -70,4 +97,7 @@ printf "<deploy>
7097 <translationimports>
7198 <path>~/Translations/*</path>
7299 </translationimports>
73- </deploy>" > src/deploy.xml | cat src/deploy.xml
100+ </deploy>" > src/deploy.xml
101+
102+ # # Echo output for logging
103+ cat src/deploy.xml
0 commit comments