br.com.objectos.git
Class GitEngine

java.lang.Object
  extended by br.com.objectos.git.GitEngine

public final class GitEngine
extends Object

A state machine providing git operations.

Since:
1

Nested Class Summary
static class GitEngine.Option
          A GitEngine configuration option.
 
Method Summary
static GitEngine.Option bufferSize(int size)
          Returns an option that sets the buffer size to the specified value.
 GitJob<Repository> copy(Repository source, ObjectId sourceId, Repository target, RefName targetRef, Copy copy)
          Copies a commit from a source repository to a target repository.
static GitEngine create(IoWorker ioWorker, GitEngine.Option... options)
          Creates and returns a new git engine instance.
static GitEngine.Option logger(br.com.objectos.core.logging.Logger logger)
          Returns an options that sets the logger instance to the specified value.
 GitJob<Directory> materialize(Repository repository, ObjectId objectId, Directory target)
           
 GitJob<Repository> openRepository(Directory directory)
           
 GitJob<Commit> readCommit(Repository repository, ObjectId id)
          Returns a new job that reads a commit object from the specified repository having the specified hash value.
 GitJob<Tree> readTree(Repository repository, ObjectId id)
          Returns a new job that reads a tree object from the specified repository having the specified hash value.
 GitJob<MaybeObjectId> resolve(Repository repository, RefName ref)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bufferSize

public static GitEngine.Option bufferSize(int size)
Returns an option that sets the buffer size to the specified value.

Parameters:
size - the buffer size
Returns:
an option that sets the buffer size to the specified value
Throws:
IllegalArgumentException - if size < 16

create

public static GitEngine create(IoWorker ioWorker,
                               GitEngine.Option... options)
Creates and returns a new git engine instance.

Options are provided by static methods in this class. The available options are:

Options provided by the GitEngine class
Method name Description Default value
bufferSize The size in bytes of the buffers used by this engine 4096
logger The logger instance the GitEngine will use NoopLogger.getInstance()

Parameters:
ioWorker - the worker for I/O tasks
options - additional configuration options
Returns:
a new git engine instance

logger

public static GitEngine.Option logger(br.com.objectos.core.logging.Logger logger)
Returns an options that sets the logger instance to the specified value.

Parameters:
logger - the logger instance
Returns:
an option that sets the logger instance to the specified value

copy

public final GitJob<Repository> copy(Repository source,
                                     ObjectId sourceId,
                                     Repository target,
                                     RefName targetRef,
                                     Copy copy)
Copies a commit from a source repository to a target repository.


materialize

public final GitJob<Directory> materialize(Repository repository,
                                           ObjectId objectId,
                                           Directory target)

openRepository

public final GitJob<Repository> openRepository(Directory directory)

readCommit

public final GitJob<Commit> readCommit(Repository repository,
                                       ObjectId id)
Returns a new job that reads a commit object from the specified repository having the specified hash value.

The returned job will fail if an object with the specified hash cannot be found, if an object with the specified hash exists but is not a commit object or if there is a parse error.

Parameters:
repository - the git repository from which to read the commit
id - the unique hash value of the commit to read
Returns:
a new job that reads a commit object
Since:
2

readTree

public final GitJob<Tree> readTree(Repository repository,
                                   ObjectId id)
Returns a new job that reads a tree object from the specified repository having the specified hash value.

The returned job will fail if an object with the specified hash cannot be found, if an object with the specified hash exists but is not a tree object or if there is a parse error.

Parameters:
repository - the git repository from which to read the tree
id - the unique hash value of the tree to read
Returns:
a new job that reads a tree object
Since:
2

resolve

public final GitJob<MaybeObjectId> resolve(Repository repository,
                                           RefName ref)


Copyright © 2020–2021 Objectos Software LTDA. All rights reserved.