 						return callback(error) if error?
 						callback()
 
-		cloneGitRepo: (repo_src, dir, callback = (error) ->) ->
+		cloneGitRepo: (service, callback = (error) ->) ->
+			repo_src = service.repo
+			dir = service.name
+			branch = service.branch
+			if !branch
+			       branch = "master"
 			if !fs.existsSync(dir)
-				proc = spawn "git", ["clone", repo_src, dir], stdio: "inherit"
+				proc = spawn "git", ["clone", "-b", branch, repo_src, dir], stdio: "inherit"
 				proc.on "close", () ->
 					callback()
 			else

		do (service) ->
			grunt.registerTask "install:#{service.name}", "Download and set up the #{service.name} service", () ->
				done = @async()
				Helpers.installService(service.repo, service.name, done)
			grunt.registerTask "update:#{service.name}", "Checkout and update the #{service.name} service", () ->
				done = @async()
				Helpers.updateService(service.name, done)

		Helpers.buildDeb @async()

	Helpers =
		installService: (service, callback = (error) ->) ->
			Helpers.cloneGitRepo service, (error) ->
				return callback(error) if error?
				Helpers.installNpmModules service.name, (error) ->
					return callback(error) if error?
					Helpers.runGruntInstall service.name, (error) ->
						return callback(error) if error?
						callback()

