Search in sources :

Example 1 with FetchOption

use of org.projectnessie.api.params.FetchOption in project nessie by projectnessie.

the class ReadCommits method execute.

@Override
public void execute() throws NessieNotFoundException {
    try (NessieApiV1 api = createNessieApiInstance()) {
        spec.commandLine().getOut().printf("Reading commits for ref '%s'\n\n", ref);
        FetchOption fetchOption = isVerbose() ? FetchOption.ALL : FetchOption.MINIMAL;
        LogResponse logResponse = api.getCommitLog().refName(ref).fetch(fetchOption).get();
        for (LogResponse.LogEntry logEntry : logResponse.getLogEntries()) {
            CommitMeta commitMeta = logEntry.getCommitMeta();
            spec.commandLine().getOut().printf("%s\t%s\t%s [%s]\n", Objects.requireNonNull(commitMeta.getHash()).substring(0, 8), commitMeta.getAuthorTime(), commitMeta.getMessage(), commitMeta.getAuthor());
            List<Operation> operations = logEntry.getOperations();
            if (operations != null) {
                for (Operation op : operations) {
                    spec.commandLine().getOut().printf("  %s\n", op);
                    if (isVerbose()) {
                        List<String> key = op.getKey().getElements();
                        for (int i = 0; i < key.size(); i++) {
                            spec.commandLine().getOut().printf("    key[%d]: %s\n", i, key.get(i));
                        }
                    }
                }
            }
        }
        spec.commandLine().getOut().printf("\nDone reading commits for ref '%s'\n\n", ref);
    }
}
Also used : LogResponse(org.projectnessie.model.LogResponse) Operation(org.projectnessie.model.Operation) CommitMeta(org.projectnessie.model.CommitMeta) NessieApiV1(org.projectnessie.client.api.NessieApiV1) FetchOption(org.projectnessie.api.params.FetchOption)

Aggregations

FetchOption (org.projectnessie.api.params.FetchOption)1 NessieApiV1 (org.projectnessie.client.api.NessieApiV1)1 CommitMeta (org.projectnessie.model.CommitMeta)1 LogResponse (org.projectnessie.model.LogResponse)1 Operation (org.projectnessie.model.Operation)1