- The project consists of many sub-projects and I don't always have all the sub-projects opened in the IDE.
- I can use the GNU command line tools on all OS platforms. When you are a developer and you are using Windows I heavily suggest that you install Cygwin. Cygwin enables you to use all sorts of GNU command line tools under Windows.
- Sometimes I have projects where I don't use an IDE at all.
At first I search for all occurences of the current version number to see where I will have to increase it:
$ egrep -Hir '1\.0\.6' | less
Then I run the following command to do the actual replacement:
$ find . -not \( -path ./.git -prune \) -type f -iregex ".*\.\(MF\|xml\|e4xmi\|java\|product\)" -print0 | xargs -0 sed -i 's/1\.0\.6/1.0.7/g'
- We don't want sed (the GNU Stream Editor which does the actual replacement) to mess around with the .git folder under any cirumstances. Therefore we exclude it from the search results (-not \( -path ./.git -prune \)). To read more about the different ways of how to exclude certain directories from a find search see here. The method above should work under any circumstances.
- We don't want sed to search for version number string in e.g. binary files (egrep omits binary files by default). Therefore we only include files with certain file extensions in the search results (-iregex ".*\.\(MF\|xml\|e4xmi\|java\|product\)").
To review the changes made by sed I use the following command (see here for an exaplanation and possible variants):
$ git diff --color-words=.
This way you can easily spot the changed characters:
|Example output of git diff --color-words=..|
|Example output of git diff when omitting the --color-words=. option.|