Search in very large SVN remote project - maven

I'm working in a very large project. I need to perform a search in all pom.xml files under a trunk folder (I've a hundred different trunk folder) in order to find if it contains a certain dependency.
I can't donwload all the svn repository, so I need to make a remote search. Is there a efficient way to do it ?
I think I should locate trunk folders, then search all pom.xml files into them before grep'ing their content to find my dependency, but I don't know how to do it on remote server :/

svn ls -R in the root of tree, grep needed files, construct full URL
svn cat URL/OF/FILE | grep PATTERN for each file

Use a combination of Find and Grep command. Similar to (not exact)
grep -R "192.168.1.5" /etc/
or with combination with Find command
find . -name “*.xml” |xargs grep -n “bla”
see here

Related

Reduce result of `find` to top level results

I have a find expression looking for node_modules directories. Some of the results are node_modules directories within a parent node_modules directory.
I'm only interested in finding the top most node_modules directory and performing an action on it, i.e. add a .metadata_never_index file so that Spotlight (macOS) doesn't index it.
I'm struggling to find a solution which deals with this; can find do this for me, or do I need to calculate it manually (maybe through string manipulations)?
As a bonus, I'd like to ignore all folders which already contain the .metadata_never_index file, if possible.
EDIT: Some context; this will run as a cron job and periodically look for node_modules in my ~/Sites directory, i.e multiple top-level projects.
After a bit more searching, I found a solution on SuperUser.
To summarise Paxali's answer:
find /home/code -type d -name ".git" | grep -v '\.git/'
In english: find me all directories named ".git" and filter out any occurences in the resultlist which contain ".git/" (dot git slash).
Except in my case, I used node_modules/ instead of .git/.
My working code:
find -f ~/Sites . -name node_modules | grep -v 'node_modules/' | while read fname; do
touch $fname/.metadata_never_index
done
Find the top most modules can be found by using
npm command with flag --depth
npm list --depth=0
you can also create aliases as follows:
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"

Script to find files in subdirectories

I need a script that will find and get me all files in all subdirectories (and leave them in the folder structure as they are now). I know how to find and print that files:
find . -name "something.extension"
The point is, in those directories are lots files that was used before, but I don't want to get those, so the script should only find me files that matches some kind of path pattern which is:
xxx/trunk/xxx/src/main/resources
xxx is different everytime, and after resources there are still some folders that directories are different based on xxx.
Every top xxx folder contains folder named 'tags' (the same level as trunk) that stores previous releases of module (and every release has files that name I am looking for, but I don't want outdated files).
So I want to find all that files in subdirectories of that path pattern that I specified and copy to new location but leave folder structure as it is right now.
I am using Windows and cygwin.
Update
I combined answer commands that 'that other guy' posted below, and it works. Just to be clear I have something like this:
find */trunk/*/src/main/resources -name "something.extension" -exec mkdir -p /absolute/target/path/{} \; -exec cp {} /absolute/target/path/{} \;
Thanks.
Instead of searching under the entire current directory (.), just search under the directories you care about:
find */trunk/*/src/main/resources -name "something.extension"

Subversion update all working copies under common parent directory

I am working on a number of projects simultaneously. Each project has a Subversion repository. The repositories are not all hosted on the same server. When I start my day, I find myself having to do an svn update for each of the individual projects.
My local working copies are all stored under one parent directory Projects.
My question: Is there a command that can be issued from the Projects directory that will search for working copies among the descendants in the file system and issue an svn update command for each of them?
I'm on Ubuntu with Subversion version 1.7.5.
cd to Projects and then:
svn up `ls -d ./*`
(note those are backticks, not single quotes.)
svn will happily skip non-svn dirs.
You could add an alias in your .bashrc
alias up-svn='svn up `ls -d ./*`'
You could just write
svn update *
That's it... Subversion will automatically recognize the working copies and do the update
One more suggestion similar to #thekbb answer
svn up `find ~/svn -maxdepth 3 -type d`
Explanation:
'~/svn' is my directory all checked out repositories are in
'-maxdepth 3' some repositories are nested (3 levels deep)
e.g. companyname/projectname/branch
'-type d' only directories
no, but you can easily write a script/batch file that calls "svn update" on each subdirectory.

How to remove all files with a specific extension from version control?

I am using Mercurial under Linux. I would like to exclude all files containing the pattern *.pro.user* from the version control system.
I tried to list all the files with:
find . -name "*.pro.user*"
This turned out also some results which are in the .hg folder:
...
./.hg/store/data/_test_run_multiple/_test_run_multiple.pro.user.i
./.hg/store/data/_test_non_dominated_sorting/_test_sorting.pro.user.i
./Analyzer/AlgorithmAnalyzer.pro.user
./Analyzer/AlgorithmAnalyzer.pro.user.a6874dd
...
I then tried to pipe this result to the hg forget command like:
find . -name "*.pro.user*" | hg forget
but I get:
abort: no files specified
My guess is that the list needs to be processed in some way in order to be passed to hg forget.
I would like to ask:
How can I pass the result of my find query into the hg forget command?
Since the query result contains files in the "private" folder .hg, is it a good idea? I hope that Mercurial will ignore that request, but shoud I remove those results somehow?
Try the following:
hg forget "set:**.pro.user*"
This tells Mercurial to forget any files that match the fileset **.pro.user*. As the fileset is defined in Mercurial, it won't go into the .hg directory. You can do even more with filesets by looking at: hg -v help filesets
The ** at the start means to work in subdirectories, rather than just the current directory.
First of all, you can use find * -name "*.pro.user*" to avoid looking in .hg.
Mercurial's forget command requires its arguments on the command line. So you need to use xargs:
find * -name "*.pro.user*" | xargs hg forget
Alternatively you can ask find to do the job:
find * -name "*.pro.user*" -exec hg forget {} \;
Finally, you should add *.pro.user* to your .hgignore file.

Find files containing text recursively in subversion repository

How can I recursively run through an entire subversion a repository and list files containing a specific text?
You could use ack (site: http://betterthangrep.com/ , I like the domain name ;) ):
It does ignore the .svn by default and runs on multiple platform, including Windows, being a Perl program.
Usage Example:
Find all #include files in C programs:
ack --cc '#include\s+<(.*)> --output '$1' -h
Testimonial example:
"Grepping of SVN repositories was driving me crazy until I found ack. It fixes all of my grep annoyances and adds features I didn't even know I wanted." --
If you have a subversion client installed, then you will be able to grab all the versioned files with this command :
svn info -R repository_root
then extract from this list the files (Path : field) and then make a grep (like this one) to extract correct files.

Resources