@Override public boolean isRegularFile() { return pathInfo.getPathType().equals( PathType.FILE ); }
synchronized DaemonService matchService( final String cmd ) { for ( final DaemonService d : services ) { if ( d.handles( cmd ) ) { return d; } } return null; }
@Override public long size() { return pathInfo.getSize(); }
public static void delete( final JGitPathImpl path, final String sessionId, final String name, final String email, final String message, final TimeZone timeZone, final Date when, final boolean amend ) { commit( path, sessionId, name, email, message, timeZone, when, amend, new HashMap<String, File>() {{ put( path.getPath(), null ); }} ); }
@Override protected void execute( final DaemonClient dc, final Repository db ) throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = uploadPackFactory.create( dc, db ); InputStream in = dc.getInputStream(); OutputStream out = dc.getOutputStream(); up.upload( in, out, null ); } }, new DaemonService( "receive-pack", "receivepack" ) {
public static List<Ref> branchList( final Git git ) { checkNotNull( "git", git ); return branchList( git, null ); }
private boolean isEnabledFor( final Repository db ) { if ( isOverridable() ) { return db.getConfig().get( configKey ).enabled; } return isEnabled(); }
public UploadPack create( DaemonClient req, Repository db ) throws ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = new UploadPack( db ); up.setTimeout( getTimeout() ); up.setPackConfig( getPackConfig() ); return up; } };
public ReceivePack create( DaemonClient req, Repository db ) throws ServiceNotEnabledException, ServiceNotAuthorizedException { ReceivePack rp = new ReceivePack( db ); InetAddress peer = req.getRemoteAddress(); String host = peer.getCanonicalHostName(); if ( host == null ) { host = peer.getHostAddress(); } String name = "anonymous"; String email = name + "@" + host; rp.setRefLogIdent( new PersonIdent( name, email ) ); rp.setTimeout( getTimeout() ); return rp; } };
public boolean deleteBranchIfExists( final JGitPathImpl path ) { final Ref branch = getBranch( path.getFileSystem().gitRepo(), path.getRefTree() ); if ( branch == null ) { return false; } JGitUtil.deleteBranch( path.getFileSystem().gitRepo(), branch ); return true; }
public ServiceConfig parse( final Config cfg ) { return new ServiceConfig( DaemonService.this, cfg, cfgName ); } };
@Override public Object fileKey() { return pathInfo.getObjectId() == null ? null : pathInfo.getObjectId().toString(); } };
/** * Lookup a supported service so it can be reconfigured. * @param name name of the service; e.g. "receive-pack"/"git-receive-pack" or * "upload-pack"/"git-upload-pack". * @return the service; null if this daemon implementation doesn't support * the requested service type. */ public synchronized DaemonService getService( String name ) { if ( !name.startsWith( "git-" ) ) { name = "git-" + name; } for ( final DaemonService s : services ) { if ( s.getCommandName().equals( name ) ) { return s; } } return null; }
public void onCloseFileSystem( final JGitFileSystem fileSystem ) { closedFileSystems.add( fileSystem ); if ( daemonService != null && closedFileSystems.size() == fileSystems.size() ) { daemonService.stop(); } }
ServiceConfig( final DaemonService service, final Config cfg, final String name ) { enabled = cfg.getBoolean( "daemon", name, service.isEnabled() ); } }
public static boolean hasBranch( final Git git, final String branchName ) { checkNotNull( "git", git ); checkNotEmpty( "branchName", branchName ); return getBranch( git, branchName ) != null; }
@Override public VersionAttributes readAttributes() throws IOException { if ( attrs == null ) { attrs = JGitUtil.buildVersionAttributes( path.getFileSystem(), path.getRefTree(), path.getPath() ); } return attrs; }
private void createBranch( final JGitPathImpl source, final JGitPathImpl target ) { JGitUtil.createBranch( source.getFileSystem().gitRepo(), source.getRefTree(), target.getRefTree() ); }
@Override public boolean isDirectory() { return pathInfo.getPathType().equals( PathType.DIRECTORY ); }
@Override protected void execute( final DaemonClient dc, final Repository db ) throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { ReceivePack rp = receivePackFactory.create( dc, db ); InputStream in = dc.getInputStream(); OutputStream out = dc.getOutputStream(); rp.receive( in, out, null ); } } };