Script to change the old folder structure to the new

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Script to change the old folder structure to the new

Ganath Rathnayake
Hi all,
I wrote a script to change the old folder structure to the new in which test
and code separated. In my previous mail I proposed the logic which I am
going to implement it. Since some issues and less number of codes I changed
the logic a bit. All the code looks as follows.

for i in applications specialpurpose framework
do
    #echo $i
cd $i

for dir in $(ls .)
do
    #echo $dir

    if [ $dir != .. ]
    then
        if [ -d $dir ]
        then
            cd $dir
            #echo $dir

            if [ -d src/ ]
            then
                echo $dir
                cd src/
                SRC=$(pwd)

                mkdir -p main/java/ test/java/
                cp -r org/ main/java/

                cd main/java/
                testdirs=$(find ./ | grep /test$)
                cd ../../

                for test in $testdirs
                do
                    cd test/java/
                    test=$(echo $test | replace test '')
                    mkdir -p $test
                    cd ../../
                    cp main/java/$test/test/*  test/java/$test
                    rm -r main/java/$test/test/
                done

                git add main/ test/
                git rm -r org/

                cd ..
            fi

            cd ..
        fi
    fi

done
cd ..
done

Though this makes the folder structure it does not change the some file
content which needs to correct to build Ofbiz successfully and run the test
successfully.
Since it is bit hard to do recursively I need address all the issues
manually and separately for correct each. So before I did it I thought of
having a file which include the changes needed to build and run tests
successfully. I will update it as soon as possible.

--
thanks
Ganath
Reply | Threaded
Open this post in threaded view
|

Re: Script to change the old folder structure to the new

Erwan de FERRIERES
Le 31/07/2011 12:27, Ganath Rathnayake a écrit :

> Hi all,
> I wrote a script to change the old folder structure to the new in which test
> and code separated. In my previous mail I proposed the logic which I am
> going to implement it. Since some issues and less number of codes I changed
> the logic a bit. All the code looks as follows.
>
> for i in applications specialpurpose framework
> do
>      #echo $i
> cd $i
>
> for dir in $(ls .)
> do
>      #echo $dir
>
>      if [ $dir != .. ]
>      then
>          if [ -d $dir ]
>          then
>              cd $dir
>              #echo $dir
>
>              if [ -d src/ ]
>              then
>                  echo $dir
>                  cd src/
>                  SRC=$(pwd)
>
>                  mkdir -p main/java/ test/java/
>                  cp -r org/ main/java/
>
>                  cd main/java/
>                  testdirs=$(find ./ | grep /test$)
>                  cd ../../
>
>                  for test in $testdirs
>                  do
>                      cd test/java/
>                      test=$(echo $test | replace test '')
>                      mkdir -p $test
>                      cd ../../
>                      cp main/java/$test/test/*  test/java/$test
>                      rm -r main/java/$test/test/
>                  done
>
>                  git add main/ test/
>                  git rm -r org/
>
>                  cd ..
>              fi
>
>              cd ..
>          fi
>      fi
>
> done
> cd ..
> done
>
> Though this makes the folder structure it does not change the some file
> content which needs to correct to build Ofbiz successfully and run the test
> successfully.
> Since it is bit hard to do recursively I need address all the issues
> manually and separately for correct each. So before I did it I thought of
> having a file which include the changes needed to build and run tests
> successfully. I will update it as soon as possible.
>
Ganath,

you can use sed to make some modifications in the files.

Cheers,

--
Erwan de FERRIERES
www.nereide.biz
Reply | Threaded
Open this post in threaded view
|

Re: Script to change the old folder structure to the new

Martin Kreidenweis
In reply to this post by Ganath Rathnayake
Hi,

> I wrote a script to change the old folder structure to the new in which test
> and code separated.

We probably want to run the script in a SVN checkout and use explicit "svn mv" commands to correctly
track renames in the repo. This is very important for later merges. Also having the file change
history kept is important to us.
I'm not sure how good the git-svn integration is in this respect.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Script to change the old folder structure to the new

Erwan de FERRIERES
Le 03/08/2011 09:13, Martin Kreidenweis a écrit :

> Hi,
>
>> I wrote a script to change the old folder structure to the new in which test
>> and code separated.
>
> We probably want to run the script in a SVN checkout and use explicit "svn mv" commands to correctly
> track renames in the repo. This is very important for later merges. Also having the file change
> history kept is important to us.
> I'm not sure how good the git-svn integration is in this respect.
>
> Martin
>
You're totally right. At the moment, Ganath is working with a github
repo. But migrating to svn will not be hard.

--
Erwan de FERRIERES
www.nereide.biz
Reply | Threaded
Open this post in threaded view
|

Re: Script to change the old folder structure to the new

Ganath Rathnayake
Hi Martin,
Yes Erwan is right it's just some simple changes to do so.

--
thanks
Ganath