Search in sources :

Example 1 with DownloadCommand

use of com.google.gerrit.extensions.config.DownloadCommand in project gerrit by GerritCodeReview.

the class ChangeJson method populateFetchMap.

public static void populateFetchMap(DownloadScheme scheme, DynamicMap<DownloadCommand> commands, String projectName, String refName, FetchInfo fetchInfo) {
    for (DynamicMap.Entry<DownloadCommand> e2 : commands) {
        String commandName = e2.getExportName();
        DownloadCommand command = e2.getProvider().get();
        String c = command.getCommand(scheme, projectName, refName);
        if (c != null) {
            addCommand(fetchInfo, commandName, c);
        }
    }
}
Also used : DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) DownloadCommand(com.google.gerrit.extensions.config.DownloadCommand)

Example 2 with DownloadCommand

use of com.google.gerrit.extensions.config.DownloadCommand in project gerrit by GerritCodeReview.

the class GetServerInfo method getDownloadSchemeInfo.

private DownloadSchemeInfo getDownloadSchemeInfo(DownloadScheme scheme, DynamicMap<DownloadCommand> downloadCommands, DynamicMap<CloneCommand> cloneCommands) {
    DownloadSchemeInfo info = new DownloadSchemeInfo();
    info.url = scheme.getUrl("${project}");
    info.isAuthRequired = toBoolean(scheme.isAuthRequired());
    info.isAuthSupported = toBoolean(scheme.isAuthSupported());
    info.commands = new HashMap<>();
    for (DynamicMap.Entry<DownloadCommand> e : downloadCommands) {
        String commandName = e.getExportName();
        DownloadCommand command = e.getProvider().get();
        String c = command.getCommand(scheme, "${project}", "${ref}");
        if (c != null) {
            info.commands.put(commandName, c);
        }
    }
    info.cloneCommands = new HashMap<>();
    for (DynamicMap.Entry<CloneCommand> e : cloneCommands) {
        String commandName = e.getExportName();
        CloneCommand command = e.getProvider().get();
        String c = command.getCommand(scheme, "${project-path}/${project-base-name}");
        if (c != null) {
            c = c.replaceAll("\\$\\{project-path\\}/\\$\\{project-base-name\\}", "\\$\\{project\\}");
            info.cloneCommands.put(commandName, c);
        }
    }
    return info;
}
Also used : CloneCommand(com.google.gerrit.extensions.config.CloneCommand) DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) DownloadCommand(com.google.gerrit.extensions.config.DownloadCommand) DownloadSchemeInfo(com.google.gerrit.extensions.common.DownloadSchemeInfo)

Aggregations

DownloadCommand (com.google.gerrit.extensions.config.DownloadCommand)2 DynamicMap (com.google.gerrit.extensions.registration.DynamicMap)2 DownloadSchemeInfo (com.google.gerrit.extensions.common.DownloadSchemeInfo)1 CloneCommand (com.google.gerrit.extensions.config.CloneCommand)1