drwxrwsr-x 7 user1 engineering 4096 Jul 30 2013 Camera.git/
--
You received this message because you are subscribed to the Google Groups "gitblit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gitblit+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import com.gitblit.extensions.LifeCycleListener;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
import com.google.inject.Inject;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ro.fortsoft.pf4j.Extension;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
/**
* Manages users and groups of all repos base on posix attributes.
*
* @author William Cork
*/
@Extension
public class GitBlitRepoPosixPlugin extends LifeCycleListener
{
final Logger log = LoggerFactory.getLogger(getClass());
final IRuntimeManager runtimeManager;
final IRepositoryManager repositoryManager;
final IUserManager userManager;
@Inject
public GitBlitRepoPosixPlugin(IRuntimeManager runtimeManager,
IRepositoryManager repositoryManager,
IUserManager userManager)
{
this.runtimeManager = runtimeManager;
this.repositoryManager = repositoryManager;
this.userManager = userManager;
}
@Override
public void onStartup()
{
try
{
//Modify repos to owner:group
modDirectoryRecursive(runtimeManager.getBaseFolder());
} catch (IOException e)
{
log.warn("GitBlitDirectoryManager failure");
}
//Reset the repo cache
repositoryManager.resetRepositoryListCache();
}
@Override
public void onShutdown()
{
//do nothing
}
private void modDirectoryRecursive(File currentDir) throws IOException
{
//Recursive search for *.git dir
//System.out.println("Entering " + currentDir.getAbsolutePath());
File[] currentFileNames = currentDir.listFiles();
if (currentFileNames == null) throw new AssertionError();
for (File file : currentFileNames)
{
if (file.isDirectory())
{
if (file.getName().matches(".*.git")) //Found a git repo
{
//Add configs.
PosixFileAttributes attrs = Files.getFileAttributeView(file.toPath(),
PosixFileAttributeView.class).readAttributes();
log.debug(this.getClass().getName() + ": Found a repo: " + file.getAbsolutePath());
Repository localRepo = new FileRepository(file.getPath() + "/.git");
StoredConfig localConfig = localRepo.getConfig();
log.debug(this.getClass().getName() + ": Configuring owner and group to: " +
attrs.owner() + ":" + attrs.group());
//Configs based on 'git config -l' on hand configured repository
// gitblit.owner=OWNER_NAME
localConfig.setString("gitblit", null, "owner", attrs.owner().getName());
// gitblit.acceptnewpatchsets=true
localConfig.setBoolean("gitblit", null, "acceptnewpatchsets", true);
// gitblit.acceptnewtickets=true
localConfig.setBoolean("gitblit", null, "acceptnewtickets", true);
// gitblit.useincrementalpushtags=false
localConfig.setBoolean("gitblit", null, "useincrementalpushtags", false);
// gitblit.allowforks=true
localConfig.setBoolean("gitblit", null, "allowforks", true);
// gitblit.accessrestriction=VIEW
localConfig.setString("gitblit", null, "accessrestriction", "VIEW");
// gitblit.authorizationcontrol=NAMED
localConfig.setString("gitblit", null, "authorizationcontrol", "NAMED");
// gitblit.verifycommitter=false
localConfig.setBoolean("gitblit", null, "verifycommitter", false);
// gitblit.showremotebranches=false
localConfig.setBoolean("gitblit", null, "showremotebranches", false);
// gitblit.isfrozen=false
localConfig.setBoolean("gitblit", null, "isfrozen", false);
// gitblit.skipsizecalculation=false
localConfig.setBoolean("gitblit", null, "skipsizecalculation", false);
// gitblit.skipsummarymetrics=false
localConfig.setBoolean("gitblit", null, "skipsummarymetrics", false);
// gitblit.federationstrategy=FEDERATE_THIS
localConfig.setString("gitblit", null, "federationstrategy", "FEDERATE_THIS");
// gitblit.isfederated=false
localConfig.setBoolean("gitblit", null, "isfederated", false);
// gitblit.gcthreshold=500k
localConfig.setString("gitblit", null, "gcthreshold", "500k");
// gitblit.lastgc=1969-12-31T16:00:00-0800
localConfig.setString("gitblit", null, "lastgc", "1969-12-31T16:00:00-0800");
//Save and close repo
localConfig.save();
localRepo.close();
//TODO: Add repo to group(attrs.group().getName()) in users.conf via java API
} else
{
//Not a repo. Enter dir.
modDirectoryRecursive(file);
}
}
//else skip
}
}
}
if (file.getName().matches(".*.git"))
Repository localRepo = new FileRepository(file.getPath() + "/.git");
Repository localRepo = new FileRepository(file.getPath() + "/.git");
I'm only intending on changing the metadata within the config file in the repository for gitblit so,works for us here.
Repository localRepo = new FileRepository(file.getPath() + "/.git");
TeamModel localTeam = userManager.getTeamModel(attrs.group().getName());
localTeam.setRepositoryPermission(file.getPath(), Constants.AccessPermission.DELETE);
[WARN ] Failed startup of context o.e.j.w.WebAppContext@4a3bd45b{/,file:/home/cxrodev/Documents/Projects/java/TestGitblitPlugin/gitblit-1.6.2/data/temp/webapp/,STARTING}{file:/home/cxrodev/Documents/Projects/java/TestGitblitPlugin/gitblit-1.6.2/gitblit.jar}java.lang.NullPointerException at ro.fortsoft.pf4j.DefaultExtensionFinder.readIndexFiles(DefaultExtensionFinder.java:153) at ro.fortsoft.pf4j.DefaultExtensionFinder.find(DefaultExtensionFinder.java:54) at ro.fortsoft.pf4j.DefaultPluginManager.getExtensions(DefaultPluginManager.java:558) at com.gitblit.manager.PluginManager.getExtensions(PluginManager.java:288) at com.gitblit.servlet.GitblitContext.configureContext(GitblitContext.java:200) at com.gitblit.servlet.GitblitContext.contextInitialized(GitblitContext.java:131) at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798) at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444) at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.server.Server.start(Server.java:387) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.Server.doStart(Server.java:354) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.gitblit.GitBlitServer.start(GitBlitServer.java:475) at com.gitblit.GitBlitServer.main(GitBlitServer.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.moxie.MxLauncher.main(MxLauncher.java:129)
2015-07-21 14:42:21 [ERROR] com.gitblit.plugin.gitblitrepoposixpermission.GitBlitRepoPosixListenerjava.lang.InstantiationException: com.gitblit.plugin.gitblitrepoposixpermission.GitBlitRepoPosixListener at java.lang.Class.newInstance(Class.java:427) at ro.fortsoft.pf4j.DefaultExtensionFinder$1.create(DefaultExtensionFinder.java:124) at ro.fortsoft.pf4j.DefaultExtensionFinder.find(DefaultExtensionFinder.java:72)
Caused by: java.lang.NoSuchMethodException: com.gitblit.plugin.gitblitrepoposixpermission.GitBlitRepoPosixListener.<init>() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 28 more