Skip to content

Commit 304ef3c

Browse files
author
Mike Leonard
committed
Added command line flag for restricting the fix-versions. The actual restriction is not yet implemented.
1 parent 768e54b commit 304ef3c

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/net/foxopen/jira/changelog/Changelog.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
*/
1010
public class Changelog {
1111

12+
public static int FIX_VERSION_RESTICT_MODE_STARTS_WITH = 10;
13+
public static int FIX_VERSION_RESTICT_MODE_LESS_THAN = 20;_OR_EQUAL
14+
1215
/**
1316
* Show usage of the application.
1417
*/
1518
public static void showUsage() {
16-
System.out.println("Usage:");
19+
System.out.println("Usage:");k
1720
System.out.println("java -jar jira-changelog-builder.jar <JIRA_URL> <JIRA_username> <JIRA_password> <JIRA_project_key> <version> <template_list> [<flags>]");
1821
System.out.println("<JIRA_URL>: The URL of the JIRA instance (e.g. https://somecompany.atlassian.net).");
1922
System.out.println("<JIRA_username>: The username used to log into JIRA.");
@@ -30,6 +33,8 @@ public static void showUsage() {
3033
System.out.println("\t--debug: Print debug/logging information to standard out. This will also force errors to go to the standard out and exit with code 0 rather than 1.");
3134
System.out.println("\t--changelog-description-field 'field_name': The name of the field in JIRA you wish to use as the changelog description field. If you do not use this, it will default to the summary field.");
3235
System.out.println("\t--eol-style (NATIVE|CRLF|LF): The type of line endings you wish the changelog files to use. Valid values are NATIVE (system line endings), CRLF (Windows line endings) or LF (UNIX line endings). If you do not use this, the changelogs will use the default system line endings.");
36+
System.out.println("\t--version-starts-with 'Version name prefix': Only display versions in the changelog that have a name starting with 'Version name prefix'. This cannot be used with --version-less-than-or-equal. This is useful for restricting what goes in the changelog if you are producing different version side-by-side.");
37+
System.out.println("\t--version-less-than-or-equal 'Version name': Only display versions in the changelog that have a name less than or equal to 'Version name'. This cannot be used with --version-starts-with. This uses a Java string comparison. This is useful for restricting what goes in the changelog if you are producing different version side-by-side.");
3338
}
3439

3540
/**
@@ -65,6 +70,8 @@ public static void main(String[] args) {
6570
String files[] = null;
6671
String objectCachePath = null;
6772
String descriptionField = null;
73+
String fixVersionRestrictMode = null;
74+
String fixVersionRestrictTerm = null;
6875
LineEnding ending = LineEnding.NATIVE; // default to native line endings
6976
for (; currentArgument < args.length; currentArgument++) {
7077
try {
@@ -100,7 +107,24 @@ public static void main(String[] args) {
100107
} else if (args[currentArgument].equals("--changelog-description-field")) {
101108
descriptionField = args[++currentArgument];
102109
Logger.log("--changelog-description-field found. Using " + descriptionField + " as the Changelog Description field.");
103-
} else {
110+
} else if (args[currentArgument].equals("--version-starts-with")) {
111+
if (fixVersionRestrictMode != null) {
112+
Logger.err("You cannot use both --version-starts-with and --version-less-than-or-equal at the same time or supply either of them more than once.");
113+
System.exit(2);
114+
}
115+
fixVersionRestrictMode = FIX_VERSION_RESTICT_MODE_STARTS_WITH
116+
fixVersionRestrictTerm = args[++currentArgument];
117+
Logger.log("--version-starts-with found. Only inlcude versions starting with " + fixVersionRestrictTerm + " in the Changelog.");
118+
} else if (args[currentArgument].equals("--version-less-than-or-equal")) {
119+
if (fixVersionRestrictMode != null) {
120+
Logger.err("You cannot use both --version-starts-with and --version-less-than-or-equal at the same time or supply either of them more than once.");
121+
System.exit(2);
122+
}
123+
fixVersionRestrictMode = FIX_VERSION_RESTICT_MODE_LESS_THAN_OR_EQUAL
124+
fixVersionRestrictTerm = args[++currentArgument];
125+
Logger.log("--version-less-than-or-equal found. Only inlcude versions with a name less than or equal to " + fixVersionRestrictTerm + " in the Changelog.");
126+
}
127+
else {
104128
Logger.err("Unknown argument: " + args[currentArgument]);
105129
System.exit(2);
106130
}

src/net/foxopen/jira/changelog/JiraAPI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ public void fetchVersionDetails(String projectKey, String versionLabel) {
131131
if (versionReleaseDate == null) {
132132
versionReleaseDate = new DateTime();
133133
}
134-
if (v.getName().equals(versionLabel) || versionReleaseDate.isBefore(buildVersion.getReleaseDate()) || versionReleaseDate.isEqual(buildVersion.getReleaseDate())) {
134+
if ((v.getName().equals(versionLabel) || versionReleaseDate.isBefore(buildVersion.getReleaseDate()) || versionReleaseDate.isEqual(buildVersion.getReleaseDate()))) {
135135
Logger.log("Version '" + v.getName() + "' was released before '" + versionLabel + "' - generating changelog.");
136136
// Attempt to get the changelog from the cache. If it can't be found
137-
// or were trying
138-
// to generate a changelog for the current version then
137+
// or were trying to generate a changelog for the current version then
139138
// build/rebuild and cache.
140139
VersionInfo vi = null;
141140
if (cache_ != null && !v.getName().equals(versionLabel)) {

0 commit comments

Comments
 (0)