public void execute ( ) throws Exception { String content = null ; String siteUrl = null ; if ( params . size ( ) == 2 ) { content = params . get ( 0 ) ; siteUrl = getSecureBaseUrl ( params . get ( 1 ) ) ; } else if ( params . size ( ) == 0 ) { System . err . println ( "The content directory and site must be specifed." ) ; System . exit ( 1 ) ; } else { System . err . println ( "Too many parameters were specified." ) ; System . exit ( 1 ) ; } GitService git = null ; try { System . out . println ( "Getting status of [" + siteUrl + "]" ) ; Status status = StatusCommand . getSiteStatus ( siteUrl , token ) ; if ( repo != null ) { status . setRepo ( repo ) ; } status . setRevision ( null ) ; System . out . println ( "Cloning repository that [" + siteUrl + "] is serving" ) ; git = CloneCommand . cloneSiteRepo ( status ) ; String revision = status . getRevision ( ) ; String branch = status . getBranch ( ) ; if ( ! UpdateCommand . isValidBranchName ( branch , UpdateRequest . CONTENT_BRANCH_PREFIX ) ) { throw new Exception ( "Cannot commit to a branch without the prefix of " + UpdateRequest . CONTENT_BRANCH_PREFIX + "." ) ; } if ( git . isTag ( branch ) ) { throw new Exception ( "Cannot commit to a tag!" ) ; } System . out . println ( "Cloning content from [" + content + "] to [" + siteUrl + ":" + branch + "]" ) ; revision = CloneCommand . cloneContent ( content , git , comment ) ; System . out . println ( "Switching content on [" + siteUrl + "]" ) ; if ( ! UpdateCommand . sendUpdateMessage ( siteUrl , null , branch , revision , comment , token ) ) { System . err . println ( "Failed to update [" + siteUrl + "]" ) ; System . exit ( 1 ) ; } } catch ( Exception e ) { System . err . println ( "Failed to commit changes to [" + siteUrl + "]: " + e . getMessage ( ) ) ; System . exit ( 1 ) ; } finally { if ( git != null ) { String dir = git . getBaseDirectory ( ) ; git . close ( ) ; FileUtils . forceDelete ( new File ( dir ) ) ; } } }
Does the work for this command .