Skip to content

Instantly share code, notes, and snippets.

@deluan
Created August 31, 2010 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deluan/559495 to your computer and use it in GitHub Desktop.
Save deluan/559495 to your computer and use it in GitHub Desktop.
Grails script to create a new Mercurial Repository for the current project, and a default .hgignore
/*
* Copyright 2010 Deluan Cotts (grails@deluan.com.br)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
HGIGNORE_CONTENTS = """
# Eclipse project files
.classpath
.project
.settings/
# IntelliJ project files
\\.iml
\\.ipr
\\.iws
.idea/
out
# Grails files and dirs that should not be versioned
target
web-app/WEB-INF/classes
web-app/WEB-INF/tld/c.tld
web-app/WEB-INF/tld/fmt.tld
stacktrace.log
plugin.xml
devDb.*
prodDb.*
# Mac OS/X finder files
.DS_Store
"""
target(main: "Creates a new Mercurial Repository for the current project, and a default .hgignore") {
println()
print "Initializing Mercurial repository.... "
proc = "hg init".execute()
result = proc.waitFor()
if (result) {
println "ERROR: ${proc.err.text}"
exit(-1)
}
println "OK"
print "Creating .hgignore..."
hgignore = new File(".hgignore")
hgignore << HGIGNORE_CONTENTS
println "OK"
println "Finished. Add your files now (with hg add)."
}
setDefaultTarget(main)
@deluan
Copy link
Author

deluan commented Aug 31, 2010

To use this script with your projects, put it in ~/.grails/scripts/HgInit.groovy, then use it like this:

$ grails hg-init

in your project base dir.

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