Skip to content

Commit 33468cf

Browse files
authored
Merge pull request #561 from TheSnoozer/operate-offline-by-default
#458: Have the plugin operate in "offline mode" by default
2 parents fc29916 + 2d9e9a6 commit 33468cf

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

core/src/main/java/pl/project13/core/AheadBehind.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
* A local git repository can either be "ahead", or "behind" in the number of commits
2424
* relative to the remote repository. This class tracks the amount of commits the local git repository
2525
* is "behind", or "ahead" relative to it's remote.
26+
*
27+
* :warning: You must set the {@code offline}-setting of the plugin to {@code false} when you want to ensure
28+
* that the properties generated are truly up-to-date. Otherwise the local state of the git repository is used
29+
* which might be out-of-date.
2630
*/
2731
public class AheadBehind {
2832

maven/docs/using-the-plugin.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,20 @@ It's really simple to setup this plugin; below is a sample pom that you may base
308308
<!-- @since 3.0.1 -->
309309
<!--
310310
Default (optional):
311-
false
311+
true
312312
313313
Explanation:
314314
When set to `true`, the plugin will not try to contact any remote repositories.
315315
Any operations will only use the local state of the repo. If set to `false`, it will
316316
execute `git fetch` operations e.g. to determine the `ahead` and `behind` branch
317317
information.
318+
319+
Warning:
320+
Before version 5.X.X the default was set to `false` causing the plugin to operate
321+
in online-mode by default. Be advised that in offline-mode the plugin might generate
322+
inaccurate `git.local.branch.ahead` and `git.local.branch.behind` branch information.
318323
-->
319-
<offline>false</offline>
324+
<offline>true</offline>
320325

321326
<!-- @since 2.1.12 -->
322327
<!--
@@ -899,8 +904,8 @@ Generated properties
899904
|`git.commit.user.email` | Represents the user eMail of the user who performed the commit. |
900905
|`git.commit.user.name` | Represents the user name of the user who performed the commit. |
901906
|`git.dirty` | A working tree is said to be "dirty" if it contains modifications which have not been committed to the current branch. |
902-
|`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`. |
903-
|`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`. |
907+
|`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. |
908+
|`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. |
904909
|`git.remote.origin.url` | Represents the URL of the remote repository for the current git project. |
905910
|`git.tags` | Represents a list of tags which contain the specified commit (`git tag --contains`). |
906911
|`git.total.commit.count` | Represents the total count of all commits in the current repository (`git rev-list HEAD --count`). |

maven/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,13 @@ public class GitCommitIdMojo extends AbstractMojo {
374374
/**
375375
* Controls whether the git plugin tries to access remote repos to fetch latest information
376376
* or only use local information.
377+
*
378+
* :warning: Before version 5.X.X the default was set to {@code false} causing the plugin to operate
379+
* in online-mode by default.
380+
*
377381
* @since 3.0.1
378382
*/
379-
@Parameter(defaultValue = "false")
383+
@Parameter(defaultValue = "true")
380384
boolean offline;
381385

382386
/**

0 commit comments

Comments
 (0)