global scans of source code

book

Article ID: 141231

calendar_today

Updated On:

Products

CA Harvest Software Change Manager CA Harvest Software Change Manager - OpenMake Meister

Issue/Introduction

Are there any new plugins or options to provide capability to do a string search across all projects/repositories?

Environment

Release : 12.6

Component : CA Harvest Software Change Manager

Resolution

Answer is not in a direct fashion, like "-en *", but it can be done. Here's one way:

The "hsv" command line utility has an option "-wp" that can let you search all the files in a selected project for a word or phrase.

For example:
C:\Users\Administrator>hsv -b scm-broker -usr harvest -pw harvest -en "SampleProject" -vp "\\" -wp "main" -s "*" -wts -oa hsv.log

C:\Users\Administrator>type hsv.log
-------------------12/4/2019 12:28:48 PM--------------------
I00060040: New connection with Broker scm-broker established.
Name Path Version Tag Data Size Package Creator Created On Modifier Modified File Modified On
----------------------------------------------------------------------------------------------------
DXY2PS.C \SampleRepository\SRC\DXY 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
DXY2PS.C \SampleRepository\SRC 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
HPGL2PS.C \SampleRepository\SRC\HPGL 0 N 2801 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:36:02
TESTPS.BAK \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:17:30
TESTPS.C \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:18:10

hsv has been executed successfully.

C:\Users\Administrator>

It can only search one project at a time, but here’s a Windows batch script that will run the same hsv command for a list of project names:

C:\Users\Administrator>type FindAllFiles.bat
echo off
setlocal enableextensions enabledelayedexpansion

REM if there was a previous log file delete it
del hsv.log

REM save our SQL statement to a file so hsql can use it
echo select environmentname from harenvironment where envisactive = 'Y' > sql.txt

REM saving both the hsql statement and the hsv statement to environment variables to make the resulting "for" statement easier to read
set hsql_command=hsql -b scm-broker -usr harvest -pw harvest -nh -f sql.txt
set hsv_command=hsv -b scm-broker -usr harvest -pw harvest -vp "\\" -s "*" -wts -oa hsv.log -wp "main"

REM here's where we loop through the list of all the project names and run hsv to search through the files
FOR /F "usebackq tokens=*" %%i IN (`%hsql_command%`) DO (
echo. >> hsv.log
echo Project: %%i >> hsv.log
%hsv_command% -en "%%i"
)

REM display the result
type hsv.log

C:\Users\Administrator>FindAllFiles.bat

C:\Users\Administrator>echo off

Project: SampleProject
-------------------12/4/2019 1:13:10 PM--------------------
I00060040: New connection with Broker scm-broker established.
Name Path Version Tag Data Size Package Creator Created On Modifier Modified File Modified On
----------------------------------------------------------------------------------------------------
DXY2PS.C \SampleRepository\SRC\DXY 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
DXY2PS.C \SampleRepository\SRC 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
HPGL2PS.C \SampleRepository\SRC\HPGL 0 N 2801 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:36:02
TESTPS.BAK \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:17:30
TESTPS.C \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:18:10

hsv has been executed successfully.

Project: AnotherProject
-------------------12/4/2019 1:13:10 PM--------------------
I00060040: New connection with Broker scm-broker established.
Name Path Version Tag Data Size Package Creator Created On Modifier Modified File Modified On
----------------------------------------------------------------------------------------------------
DXY2PS.C \SampleRepository\SRC\DXY 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
DXY2PS.C \SampleRepository\SRC 0 N 1864 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:35:42
HPGL2PS.C \SampleRepository\SRC\HPGL 0 N 2801 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 08-09-1989;00:36:02
TESTPS.BAK \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:17:30
TESTPS.C \SampleRepository\SRC 0 N 2035 BASE harvest 10-24-2019;09:20:21 harvest 10-24-2019;09:20:21 09-08-1995;05:18:10

hsv has been executed successfully.

C:\Users\Administrator>