Skip to content

Commit

Permalink
Issue #309: allowed other repositories to use releasenotes builder
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and romani committed Jun 24, 2018
1 parent 42cf0fa commit f4249ac
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
6 changes: 5 additions & 1 deletion releasenotes-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Jar file which includes all required dependencies will be located at

## Command line usage
```
java -jar releasenotes-builder-1.0-all.jar -localRepoPath <arg> -startRef <arg> [-endRef <arg>] \
java -jar releasenotes-builder-1.0-all.jar -localRepoPath <arg> \
-remoteRepoPath <arg> -startRef <arg> [-endRef <arg>] \
-releaseNumber <arg> [-outputLocation <args>] [-githubAuthToken <arg>] \
[-generateAll] [-generateXdoc] [-generateTwit] [-generateRss] [-generateGplus] [-generateMlist] \
[-publishXdoc] [-publishXdocWithPush] \
Expand All @@ -34,6 +35,8 @@ Command line options are:

**localRepoPath** - path to the local git repository. For example, ```/home/user/checkstyle``` .

**remoteRepoPath** - path to the remote github repository. For example, ```checkstyle/checkstyle``` .

**startRef** - specifies the commit reference or tag from which to start the generation of
release notes. For example, ```753bc06``` or just tag ```checkstyle-6.12.1``` .

Expand Down Expand Up @@ -102,5 +105,6 @@ The following example demonstrates how to generate releasenotes.xml for checksty

```
java -jar releasenotes-builder-1.0-all.jar -localRepoPath /home/user/checkstyle/ \
-remoteRepoPath checkstyle/checkstyle \
-startRef checkstyle-6.12.1 -releaseNumber 6.13 -generateAll
```
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public final class CliOptions {

/** Path to a local git repository. */
private String localRepoPath;
/** Path to remote github repository. */
private String remoteRepoPath;
/** Start reference. */
private String startRef;
/** End reference. */
Expand Down Expand Up @@ -103,6 +105,10 @@ public String getLocalRepoPath() {
return localRepoPath;
}

public String getRemoteRepoPath() {
return remoteRepoPath;
}

public String getStartRef() {
return startRef;
}
Expand Down Expand Up @@ -226,6 +232,17 @@ public Builder setLocalRepoPath(String path) {
return this;
}

/**
* Specify Remote repository path.
* @param path Remote repository path
* @return Builder Object
* @noinspection ReturnOfInnerClass
*/
public Builder setRemoteRepoPath(String path) {
remoteRepoPath = path;
return this;
}

/**
* Specify Start git reference.
* @param ref Start reference
Expand Down Expand Up @@ -537,6 +554,8 @@ public CliOptions build() {
}
Verify.verifyNotNull(localRepoPath,
"Path to a local git repository should not be null!");
Verify.verifyNotNull(remoteRepoPath,
"Path to a remote github repository should not be null!");
Verify.verifyNotNull(startRef, "Start reference should not be null!");
Verify.verifyNotNull(releaseNumber, "Release number should not be null!");

Expand Down Expand Up @@ -662,9 +681,11 @@ private void loadSfRssProperties() {
* Get new CliOptions instance.
* @return new CliOptions instance.
*/
// -@cs[ExecutableStatementCount] long list of options being assigned to single instance
private CliOptions getNewCliOptionsInstance() {
final CliOptions cliOptions = new CliOptions();
cliOptions.localRepoPath = localRepoPath;
cliOptions.remoteRepoPath = remoteRepoPath;
cliOptions.startRef = startRef;
cliOptions.endRef = endRef;
cliOptions.releaseNumber = releaseNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class CliProcessor {

/** Name for the option 'localRepoPath'. */
private static final String OPTION_LOCAL_REPO_PATH = "localRepoPath";
/** Name for the option 'remoteRepoPath'. */
private static final String OPTION_REMOTE_REPO_PATH = "remoteRepoPath";
/** Name for the option 'startRef'. */
private static final String OPTION_START_REF = "startRef";
/** Name for the option 'endRef'. */
Expand Down Expand Up @@ -157,6 +159,9 @@ private List<String> validateCli() {
localGitRepositoryPath));
}
}
if (!cmdLine.hasOption(OPTION_REMOTE_REPO_PATH)) {
result.add("Remote repository path has not been specified!");
}
if (!cmdLine.hasOption(OPTION_START_REF)) {
result.add("Start reference has not been specified!");
}
Expand All @@ -179,6 +184,7 @@ private List<String> validateCli() {
public CliOptions getCliOptions() {
return CliOptions.newBuilder()
.setLocalRepoPath(cmdLine.getOptionValue(OPTION_LOCAL_REPO_PATH))
.setRemoteRepoPath(cmdLine.getOptionValue(OPTION_REMOTE_REPO_PATH))
.setStartRef(cmdLine.getOptionValue(OPTION_START_REF))
.setEndRef(cmdLine.getOptionValue(OPTION_END_REF))
.setReleaseNumber(cmdLine.getOptionValue(OPTION_RELEASE_NUMBER))
Expand Down Expand Up @@ -217,6 +223,7 @@ public CliOptions getCliOptions() {
private static Options buildOptions() {
final Options options = new Options();
options.addOption(OPTION_LOCAL_REPO_PATH, true, "Path to a local git repository.");
options.addOption(OPTION_REMOTE_REPO_PATH, true, "Path to a remote github repository.");
options.addOption(OPTION_START_REF, true, "Start reference to grab commits from.");
options.addOption(OPTION_END_REF, true, "End reference to stop grabbing the commits.");
options.addOption(OPTION_RELEASE_NUMBER, true, "Release number.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
*/
public final class Main {

/** A path to remote checkstyle repository. */
private static final String REMOTE_REPO_PATH = "checkstyle/checkstyle";

/** Filename for a generated xdoc. */
private static final String XDOC_FILENAME = "xdoc.xml";
/** Filename for a generated Twitter post. */
Expand Down Expand Up @@ -142,7 +139,7 @@ private static Result runNotesBuilder(CliOptions cliOptions)
connection = GitHub.connectUsingOAuth(authToken);
}

final GHRepository remoteRepo = connection.getRepository(REMOTE_REPO_PATH);
final GHRepository remoteRepo = connection.getRepository(cliOptions.getRemoteRepoPath());
final Result result = NotesBuilder.buildResult(remoteRepo, localRepoPath, startRef, endRef);
if (result.hasWarnings()) {
printListOf(result.getWarningMessages());
Expand Down

0 comments on commit f4249ac

Please sign in to comment.