Class 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:
    - the version attribute set to the release version This class is not meant to be used in multi-threaded environments.
    • Constructor Detail

      • Infer

        public Infer​(State state,
                     Repository repository)
        Standard constructor.
        Parameters:
        state - the state reference
        repository - the repository reference
        Throws:
        NullPointerException - if a given argument is null
    • Method Detail

      • isUpToDate

        public boolean isUpToDate()
                           throws DataAccessException,
                                  IllegalPropertyException,
                                  GitException
        Returns true 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 returns true 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
        - the version 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
        - the releaseScope/previousVersion and releaseScope/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 be null;
        - the releaseScope/initialCommit is defined with the SHA-1 of the commit right after the releaseScope/previousVersionCommit or, when releaseScope/previousVersionCommit can't be inferred, the repository root commit SHA-1 is used; if the user overrides the version by configuration this value remains null - releaseScope/significant is true 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()