Created
February 29, 2012 00:33
-
-
Save seancoyne/1936523 to your computer and use it in GitHub Desktop.
ColdFusion script to create a new SVN tag from trunk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfsetting enablecfoutputonly="true" /> | |
| <!--- @@displayname: Build Script ---> | |
| <!--- @@author: Sean Coyne (www.n42designs.com) ---> | |
| <!--- @@description: Copies the current trunk to a new tag ---> | |
| <!--- set the following variables to the proper URI for each (trunk, tags) ---> | |
| <cfset variables.svnUri = "https://base/url/path" /> | |
| <cfset variables.trunkUri = variables.svnUri & "/trunk" /> | |
| <cfset variables.tagsUri = variables.svnUri & "/tags" /> | |
| <!--- set the following to the full path to the svn executable ---> | |
| <cfset variables.svnPath = "/usr/bin/svn" /> | |
| <!--- set the svn credentials ---> | |
| <cfset variables.svnUsername = "myusername" /> | |
| <cfset variables.svnPassword = "mypassword" /> | |
| <!--- ensure path to SVN is valid ---> | |
| <cfif not fileExists(variables.svnPath)> | |
| <cfoutput><p>Can't find SVN at #variables.svnPath#</p></cfoutput> | |
| <cfabort /> | |
| </cfif> | |
| <cfif structKeyExists(form,"nextTag")> | |
| <!--- ensure we have a tag ID ---> | |
| <cfif not len(trim(form.nextTag))> | |
| <cfoutput><p>You must specify a tag. <a href="build.cfm">Continue</a></p></cfoutput> | |
| <cfabort /> | |
| </cfif> | |
| <!--- default to no message ---> | |
| <cfparam name="form.message" default="" /> | |
| <!--- create the tag ---> | |
| <cfset args = "copy #variables.trunkUri# #variables.tagsUri#/#form.nextTag# -m ""#form.message#"" --username #variables.svnUsername# --password #variables.svnPassword#" /> | |
| <cfexecute variable="results" name="#variables.svnPath#" arguments="#args#" timeout="9999999" /> | |
| <cfoutput><h1>Tag #form.nextTag# created!</h1></cfoutput> | |
| <cfelse> | |
| <!--- first, get the last tag so we can ask the user for a tag ID and set a default ---> | |
| <cfexecute name="#variables.svnPath#" arguments="list #variables.tagsUri# --username #variables.svnUsername# --password #variables.svnPassword#" variable="results" timeout="9999999" /> | |
| <!--- result is a new line delimited list, turn it into an array ---> | |
| <cfset tags = listToArray(results," #chr(10)##chr(13)#") /> | |
| <!--- grab the last tag ---> | |
| <Cfset lastTag = tags[arrayLen(tags)] /> | |
| <!--- remove trailing slash ---> | |
| <cfset lastTag = replace(lastTag,"/","","ALL") /> | |
| <!--- ask the user what the next tag ID should be, if in 0.0.0 format, increment the last number and offer that as a default ---> | |
| <cfif isNumeric(listLast(lastTag,".")) and listLen(lastTag,".") gt 1> | |
| <cfset nextTag = reverse(listRest(reverse(lastTag),".")) & "." & (listLast(lastTag,".") + 1) /> | |
| <cfelse> | |
| <cfset nextTag = "" /> | |
| </cfif> | |
| <cfoutput> | |
| <html> | |
| <head> | |
| <title>Create New Tag</title> | |
| </head> | |
| <body> | |
| <form action="build.cfm" method="post"> | |
| <p>Copying <strong>#variables.trunkUri#</strong> | |
| <label for="nextTag">to <strong>#variables.tagsUri#/</strong><input type="text" name="nextTag" id="textTag" value="#nextTag#"></label></p> | |
| <p><label for="message">Commit Message:</label><br> | |
| <textarea name="message" id="message" style="width:200px;height:50px;">creating tag #nextTag#</textarea><br> | |
| <button type="submit">Create Tag</button></p> | |
| </form> | |
| </body> | |
| </html> | |
| </cfoutput> | |
| </cfif> | |
| <cfsetting enablecfoutputonly="false" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment