M y B l o g

Get work product using SVN and Shell Script.

In this article, I'll demonstrate how to use SVN command and Shell Script to get link of work product I have made in a month.
SVN stands for Subversion. So, SVN and Subversion are the same. SVN is used to manage and track changes to code and assets across projects.
Monthly, I have to list all the paths of work products such as Word, Excel, .c, .h files... For example, if I list manually all links as shown below, I will take a lot of time to find them.

1
2
3
4
5
6
7
8
9
10
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/H3/GPT/UT/R-CarH3_MCAL_GPT_UTReport.xlsx
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/H3/GPT/UT/Review_Minutes/R-CarH3_MCAL_GPT_UT_PeerReviewMinutes.xlsm
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/H3/MCU/IT/Review_Minutes/R-CarH3_MCAL_MCU_IT_PR_Checklist.xlsm
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/Coverage/R-CarM3_MCAL_GPT_DriverCoverageReport.xlsm
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/Archive_folder/ConfigurationIT/EvalEnvelope_20210327.zip
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/Archive_folder/ConfigurationIT/EvalEnvelope_20210401.zip
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/Archive_folder/DriverIT/EvalEnvelope_20210409.zip
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/R-CarM3_MCAL_GPT_ConfigurationITReport.xlsx
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/R-CarM3_MCAL_GPT_DriverITReport.xlsx
http://(hidden_name)/Maintenance/branches/Maintenance_branch/07_Test_Report/M3/GPT/IT/R-CarM3_MCAL_GPT_PerformanceITReport.xlsx

In reality, the number of links can be two or three times higher. So, in order to save time, I created this tool to get all links quickly.

Demo:

● Run command: sh Deliverable.sh.


● We will wait for it to run and this script will generate the output file res.txt. The time the script runs depends on the network speed and the number of files that we do.


● Then, we just copy the result and paste into the report.


Now we will reseach how this script work.

● Due to I have to make the report monthly, I set the date is from {2021-03-25} to {2021-04-25} and user name is my name (bv_kiettran).

1
2
3
4
5
#Choose the date
chooseDate='{2021-03-25}:{2021-04-25}'

#Change your SVN name
yourName="bv_kiettran"

● I use this command to see a log message of work product. This is a log message of a work product. It will display all information such as date, author, revision, path...

1
svn log -v 'hidden_repository' -r {2021-03-25}:{2021-04-25} | sed -n "/$bv_kiettran/,/-----$/ p"

● This is a log message of a work product. It will display all information such as date, author, revision, path... but I only need the path (red box as shown below), so I will use "grep"command and store these paths to a temporary file.


1
svn log -v 'hidden_repository' -r {2021-03-25}:{2021-04-25} | sed -n "/$bv_kiettran/,/-----$/ p" | grep "M /\|A /" > temp.txt

● Now, the temporary file contains the following:


● Finally, I just replace "M /" and "A /" into your repository address bu using "sed" command. Then the result will be stored to another temporary file.


1
sed 's|   M |http://(hidden_repository)|g;s|   A |http://(hidden_repository)|g' temp.txt > temp1.txt

Here is full of script.


1
2
3
4
5
6
7
8
9
10
11
12
#Choose the date
chooseDate='{2021-03-25}:{2021-04-25}'

#Change your SVN name
yourName="bv_kiettran"

echo "Please wait..."
svn log -v 'hidden_repository' -r $chooseDate | sed -n "/$yourName/,/-----$/ p" | grep "M /\|A /" > temp.txt
sed 's|   M |hidden_repository|g;s|   A |hidden_repository|g' temp.txt > temp1.txt
sort -u temp1.txt > res.txt
echo "Done! Check result in file res.txt"
rm -f temp.txt temp1.txt

Thank you for taking the time to read!