Package com.mooltiverse.oss.nyx.command
Class Infer
- java.lang.Object
-
- com.mooltiverse.oss.nyx.command.AbstractCommand
-
- com.mooltiverse.oss.nyx.command.Infer
-
- All Implemented Interfaces:
Command
public class Infer extends AbstractCommand
The Infer command takes care of inferring and computing informations in order to make a new release. After this task is executed the state object has:
- theversion
attribute set to the release version This class is not meant to be used in multi-threaded environments.
-
-
Constructor Summary
Constructors Constructor Description Infer(State state, Repository repository)
Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isUpToDate()
Returnstrue
if this command is up to date, which means that the internal state (Command.state()
) would not change by running (Command.run()
) the command again.State
run()
Infers all the required informations to produce a new release from the Git repository.-
Methods inherited from class com.mooltiverse.oss.nyx.command.AbstractCommand
getLatestCommit, isInternalAttributeUpToDate, isRepositoryClean, repository, state, storeInternalAttribute
-
-
-
-
Constructor Detail
-
Infer
public Infer(State state, Repository repository)
Standard constructor.- Parameters:
state
- the state referencerepository
- the repository reference- Throws:
NullPointerException
- if a given argument isnull
-
-
Method Detail
-
isUpToDate
public boolean isUpToDate() throws DataAccessException, IllegalPropertyException, GitException
Returnstrue
if this command is up to date, which means that the internal state (Command.state()
) would not change by running (Command.run()
) the command again. It other words, when this method returnstrue
any invocation of the (Command.run()
) method is needless and idempotent about the state. This method uses the quickest method to verify whether the state is up to date or not. This method must not rely on dependencies and it must always evaluate its own status independently. As a general rule this method checks if its inputs (i.e. from the configuration) have changed since the last run.- Returns:
true
if this command is up to date- Throws:
DataAccessException
- in case the configuration can't be loaded for some reason.IllegalPropertyException
- in case the configuration has some illegal options.GitException
- in case of unexpected issues when accessing the Git repository.- See Also:
Command.state()
,Command.run()
-
run
public State run() throws DataAccessException, IllegalPropertyException, GitException, ReleaseException
Infers all the required informations to produce a new release from the Git repository.
Inputs to this task are:
- the Git repository and the commit history;
Outputs from this task are all stored in the State object, with more detail:
-bump
is the version identifier that was bumped to get the new version; it's undefined if the user has overridden the version by configuration or no previous versions to bump can be found in the history or the release scope doesn't have significant commits
- theversion
is defined with the new version identifier for the new release; if the user has overridden the version by configuration that value is simply used and no inference is done; if the version is not overridden by configuration and no previous versions can be found in the history the initial version from the configuration is used
- thereleaseScope/previousVersion
andreleaseScope/previousVersionCommit
are defined with the tag and SHA-1 of the previous release, if any; if no previous release is found or the version was overridden by the user configuration they will benull
;
- thereleaseScope/initialCommit
is defined with the SHA-1 of the commit right after thereleaseScope/previousVersionCommit
or, whenreleaseScope/previousVersionCommit
can't be inferred, the repository root commit SHA-1 is used; if the user overrides the version by configuration this value remainsnull
-releaseScope/significant
istrue
if the release scope contains significant commits (commits whose messages bring informations about new versions)- Returns:
- the updated reference to the state object. The returned object is the same instance passed in the constructor.
- Throws:
DataAccessException
- in case the configuration can't be loaded for some reason.IllegalPropertyException
- in case the configuration has some illegal options.GitException
- in case of unexpected issues when accessing the Git repository.ReleaseException
- if the task is unable to complete for reasons due to the release process.- See Also:
isUpToDate()
,AbstractCommand.state()
-
-