Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SVN Revert command. #88

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

xforever1313
Copy link
Member

This commit adds the SVN Revert command as a Cake Alias. It allows one to pass in a single file, a single directory, multiple files via a FilePathCollection, multiple directories via a DirectoryPathCollection, or both types of collections.

Testing

Test 1: Revert a single file.

Cakefile used:

#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Sharp.Svn.dll"
#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Cake.Svn.dll"

const string target = "revert";

Task( target )
.Does(
    () =>
    {
        FilePath file = File( "./TestRepoCo/Test.txt" );

        bool success = SvnRevert( file );
        Information( "Revert: " + success );
    }
);

RunTarget( target );

SVN Status Before:

> svn status
M       Test.txt

Running Cake File:

> cake ..\build.cake

========================================
revert
========================================
Revert: True

Task                          Duration
--------------------------------------------------
revert                        00:00:00.1066210
--------------------------------------------------
Total:                        00:00:00.1066210

> svn status
>

Test 2: Revert a directory

Cakefile Used:

#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Sharp.Svn.dll"
#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Cake.Svn.dll"

const string target = "revert";

Task( target )
.Does(
    () =>
    {
        SvnRevertSettings settings = new SvnRevertSettings
        {
            Depth = SvnDepth.Infinity
        };
        DirectoryPath dir = Directory( "./TestRepoCo/MyFolder" );

        bool success = SvnRevert( dir, settings );
        Information( "Revert: " + success );
    }
);

RunTarget( target );

SVN Status Before:

> svn status
M       MyFolder\Test2.txt
M       MyFolder\Test3.txt

Running Cake File:

> cake ..\build.cake

========================================
revert
========================================
Revert: True

Task                          Duration
--------------------------------------------------
revert                        00:00:00.1070694    
--------------------------------------------------
Total:                        00:00:00.1070694    
> svn status        
>

Test 3: Revert a glob of files:

Cakefile Used:

#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Sharp.Svn.dll"
#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Cake.Svn.dll"

const string target = "revert";

Task( target )
.Does(
    () =>
    {
        SvnRevertSettings settings = new SvnRevertSettings
        {
            Depth = SvnDepth.Infinity
        };
        FilePathCollection files = GetFiles( "./TestRepoCo/*.txt" );

        bool success = SvnRevert( files, settings );
        Information( "Revert: " + success );
    }
);

RunTarget( target );

SVN Status Before:

> svn status
M       HtmlTest.html
M       Test.txt
M       Test4.txt

Running Cake File (txt files reverted, html file was not):

PS C:\Users\xfore.000\Downloads\TestRepoCo> cake ..\build.cake

========================================
revert
========================================
Revert: True

Task                          Duration
--------------------------------------------------
revert                        00:00:00.5200734    
--------------------------------------------------
Total:                        00:00:00.5200734    

> svn status
M       HtmlTest.html
>

Test 4: Reverting a Glob of directories:

Cake file used:

#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Sharp.Svn.dll"
#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Cake.Svn.dll"

const string target = "revert";

Task( target )
.Does(
    () =>
    {
        SvnRevertSettings settings = new SvnRevertSettings
        {
            Depth = SvnDepth.Infinity
        };
        DirectoryPathCollection dirs = GetDirectories( "./TestRepoCo/MyFolder*" );

        bool success = SvnRevert( dirs, settings );
        Information( "Revert: " + success );
    }
);

RunTarget( target );

SVN Status Before:

> svn status
M       HtmlTest.html
M       MyFolder\Test2.txt
M       MyFolder\Test3.txt
M       MyFolder2\Test2.txt
M       MyFolder2\Test3.txt
> 

Running Cake File (HTML File, which is not in a directory, not reverted as expected):

> cake ..\build.cake

========================================
revert
========================================
Revert: True

Task                          Duration
--------------------------------------------------
revert                        00:00:00.6695536    
--------------------------------------------------
Total:                        00:00:00.6695536    
> svn status
M       HtmlTest.html

Test 5: Revert files and directories:

Cakefile Used:

#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Sharp.Svn.dll"
#reference "C:\\Users\\xfore\\Documents\\Source\\Cake.Svn\\src\\Cake.Svn\\bin\\Debug\\Cake.Svn.dll"

const string target = "revert";

Task( target )
.Does(
    () =>
    {
        SvnRevertSettings settings = new SvnRevertSettings
        {
            Depth = SvnDepth.Infinity
        };
        DirectoryPathCollection dirs = GetDirectories( "./TestRepoCo/MyFolder*" );
        FilePathCollection files = GetFiles( "./TestRepoCo/*.txt" );

        bool success = SvnRevert( files, dirs, settings );
        Information( "Revert: " + success );
    }
);

RunTarget( target );

SVN Status Before:

> svn status
M       HtmlTest.html
M       MyFolder\Test2.txt
M       MyFolder\Test3.txt
M       MyFolder2\Test2.txt
M       MyFolder2\Test3.txt
M       Test.txt
M       Test4.txt

Running Cake File (HTML File, which is not in the glob, left alone)

PS C:\Users\xfore.000\Downloads\TestRepoCo> cake ..\build.cake

========================================
revert
========================================
Revert: True

Task                          Duration
--------------------------------------------------
revert                        00:00:00.2209471
--------------------------------------------------
Total:                        00:00:00.2209471
> svn status        
M       HtmlTest.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants