Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / update_gitignore.sh
blobd23b4e5bf9831dfda0f9f186f5e53696b520aa32
1 #!/usr/bin/env bash
3 cmd="$1"
4 if [[ "$cmd" == "help" ]] || [[ "$cmd" != "run" && "$cmd" != "dry-run" ]]
5 then
6 if [[ "$cmd" != "help" ]]
7 then
8 echo "Error: Unrecognized command '$0 $1'"
9 echo ""
12 echo "Usage:"
13 echo " update_gitignore.sh run"
14 echo " update_gitignore.sh dry-run"
15 echo ""
16 echo "This command finds all untracked and un-git-add-ed files in the repository and adds each file name to "
17 echo "a '.gitignore' file in the same directory. If a '.gitignore' file does not exist, one will be created. "
18 echo "Otherwise, the existing '.gitignore' file will be appended to. The 'dry-run' command enables you to "
19 echo "see a list of all detected file names that will be added to '.gitignore' files without making any "
20 echo "changes."
21 echo ""
22 echo "If the 'run' command does its job properly, running 'dry-run' immediately after should display no "
23 echo "planned actions."
25 if [[ "$cmd" == "help" ]]
26 then
27 exit 0
30 exit 1
33 export IFS=$'\n';
35 for line in $(git status --short --untracked-files)
37 if [[ $line == '??'* ]]
38 then
39 file="${line:3}"
40 d="$(dirname "${file}")"
41 f="$(basename "${file}")"
43 if [[ "$cmd" == "run" ]]
44 then
45 echo "Ignoring ${f} in ${d}/.gitignore"
46 echo "${f}" >> "${d}/.gitignore"
47 else
48 echo "Will ignore ${f} in ${d}/.gitignore"
51 done