Skip to content

#458: Have the plugin operate in "offline mode" by default #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/main/java/pl/project13/core/AheadBehind.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* A local git repository can either be "ahead", or "behind" in the number of commits
* relative to the remote repository. This class tracks the amount of commits the local git repository
* is "behind", or "ahead" relative to it's remote.
*
* :warning: You must set the {@code offline}-setting of the plugin to {@code false} when you want to ensure
* that the properties generated are truly up-to-date. Otherwise the local state of the git repository is used
* which might be out-of-date.
*/
public class AheadBehind {

Expand Down
13 changes: 9 additions & 4 deletions maven/docs/using-the-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,20 @@ It's really simple to setup this plugin; below is a sample pom that you may base
<!-- @since 3.0.1 -->
<!--
Default (optional):
false
true

Explanation:
When set to `true`, the plugin will not try to contact any remote repositories.
Any operations will only use the local state of the repo. If set to `false`, it will
execute `git fetch` operations e.g. to determine the `ahead` and `behind` branch
information.

Warning:
Before version 5.X.X the default was set to `false` causing the plugin to operate
in online-mode by default. Be advised that in offline-mode the plugin might generate
inaccurate `git.local.branch.ahead` and `git.local.branch.behind` branch information.
-->
<offline>false</offline>
<offline>true</offline>

<!-- @since 2.1.12 -->
<!--
Expand Down Expand Up @@ -899,8 +904,8 @@ Generated properties
|`git.commit.user.email` | Represents the user eMail of the user who performed the commit. |
|`git.commit.user.name` | Represents the user name of the user who performed the commit. |
|`git.dirty` | A working tree is said to be "dirty" if it contains modifications which have not been committed to the current branch. |
|`git.local.branch.ahead` | Represents the count of commits that your local branch is ahead in perspective to the remote branch (usually the case when your local branch has committed changes that are not pushed yet to the remote branch). Note: To obtain the right value for this property this plugin will perform a `git fetch`. |
|`git.local.branch.behind` | Represents the count of commits that your local branch is behind in perspective to the remote branch (usually the case when there are commits in the remote branch that are not yet integrated into your local branch). Note: To obtain the right value for this property this plugin will perform a `git fetch`. |
|`git.local.branch.ahead` | Represents the count of commits that your local branch is ahead in perspective to the remote branch (usually the case when your local branch has committed changes that are not pushed yet to the remote branch). Note: To obtain the right value for this property this plugin should operate in online mode (`<offline>false</offline>`) so a `git fetch` will be performed before retrieval. |
|`git.local.branch.behind` | Represents the count of commits that your local branch is behind in perspective to the remote branch (usually the case when there are commits in the remote branch that are not yet integrated into your local branch). Note: To obtain the right value for this property this plugin should operate in online mode (`<offline>false</offline>`) so a `git fetch` will be performed before retrieval. |
|`git.remote.origin.url` | Represents the URL of the remote repository for the current git project. |
|`git.tags` | Represents a list of tags which contain the specified commit (`git tag --contains`). |
|`git.total.commit.count` | Represents the total count of all commits in the current repository (`git rev-list HEAD --count`). |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,13 @@ public class GitCommitIdMojo extends AbstractMojo {
/**
* Controls whether the git plugin tries to access remote repos to fetch latest information
* or only use local information.
*
* :warning: Before version 5.X.X the default was set to {@code false} causing the plugin to operate
* in online-mode by default.
*
* @since 3.0.1
*/
@Parameter(defaultValue = "false")
@Parameter(defaultValue = "true")
boolean offline;

/**
Expand Down