Mercurial > hg > icedrobot > ika
view src/org/icedrobot/ika/plugins/git/IkaGitWrapper.java @ 7:4e841dd81d28
Add new plugin: create new git repository for icedrobot.
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Tue, 15 Mar 2011 00:13:34 +0100 |
parents | 2bd34951aadf |
children |
line wrap: on
line source
/* * IKA - IcedRobot Kiosk Application * Copyright (C) 2011 IcedRobot team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.icedrobot.ika.plugins.git; import java.io.File; import joptsimple.OptionParser; import joptsimple.OptionSet; import org.icedrobot.ika.plugins.IkaPlugin; import org.icedrobot.ika.plugins.IkaPluginResult; import org.icedrobot.ika.plugins.scm.GITRepository; import org.icedrobot.ika.plugins.scm.HGRepository; import org.icedrobot.ika.plugins.scm.Repository; /** * @author Mario Torre <neugens.limasoftware@gmail.com> */ public class IkaGitWrapper implements IkaPlugin { @Override public String getName() { return "git"; } @Override public String getDescription() { return "handles various git tasks for IcedRobot"; } @Override public IkaPluginResult execute(String[] args) { if (args != null) { OptionParser parser = new OptionParser(); parser.accepts("makerepo").withRequiredArg(); OptionSet options = parser.parse(args); if (options.has("makerepo")) { String destinationDir = (String) options.valueOf("makerepo"); File base = new File(destinationDir); if (!base.exists()) { System.out.println("desitination directory doesn't exist"); return IkaPluginResult.FAILURE; } System.err.println("base.getName(): " + base.getName()); Repository repository = new GITRepository(base.getName(), base, "", "", "icedrobot"); repository.create(); repository.initPatchQueue(); String s = File.separator; File basePath = new File(repository.getFullPath() + s + ".git" + s + "patches"); Repository hgRepo = new HGRepository(base.getName(), basePath, "", ""); hgRepo.create(); return IkaPluginResult.OK; } } displayUsage(); return IkaPluginResult.OK; } private void displayUsage() { System.out.println("Usage: ika git --makerepo=" + "<destination directory>"); System.out.println("\t--makerepo"); System.out.println("\t\t\tdirectory where to create the " + "new git repository"); System.out.println("\t\t\tThis argument is mandatory."); System.out.println("\t\t\tThe respository is created with a default"); System.out.println("\t\t\t\"icedrobot\" branch"); } }