Skip to content

Commit

Permalink
[tmp]
Browse files Browse the repository at this point in the history
  • Loading branch information
minh committed Jul 15, 2024
1 parent 7aec27f commit fb7e3a3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/java/org/nqm/Gis.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.nqm;

import java.io.IOException;
import java.nio.file.Path;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.nqm.command.GisCommand;
import org.nqm.command.GisVersion;
import org.nqm.command.GitStatusCommand;
import org.nqm.config.GisLog;
import org.nqm.utils.GisProcessUtils;
import picocli.CommandLine;
Expand Down Expand Up @@ -38,16 +43,16 @@ public static void setDryRun(boolean dryRun) {
}

public static void main(String... args) {
// try {
// System.out.println(GitStatusCommand.status(Path.of("/home/minh/projects/test/small-git-root-module/small-git-domain/.git"), false));
// } catch (NoWorkTreeException | IOException | GitAPIException e) {
// e.printStackTrace();
// }
try {
System.out.println(GitStatusCommand.status(Path.of("/home/minh/projects/test/small-git-root-module/small-git-craft/.git"), false));
} catch (NoWorkTreeException | IOException | GitAPIException e) {
e.printStackTrace();
}

var gis = new CommandLine(new Gis());
gis.setExecutionExceptionHandler(GLOBAL_EXCEPTION_HANLER);
gis.execute(args.length == 0
? new String[] {GIT_STATUS, "--one-line"}
: args);
// var gis = new CommandLine(new Gis());
// gis.setExecutionExceptionHandler(GLOBAL_EXCEPTION_HANLER);
// gis.execute(args.length == 0
// ? new String[] {GIT_STATUS, "--one-line"}
// : args);
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/nqm/command/GitStatusCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.nqm.utils.StdOutUtils.coloringBranch;
import static org.nqm.utils.StdOutUtils.coloringWord;
import static org.nqm.utils.StdOutUtils.infof;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -26,11 +27,19 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RenameDetector;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.BranchConfig;
import org.eclipse.jgit.lib.BranchTrackingStatus;
import org.eclipse.jgit.lib.RefRename;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommitList;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.submodule.SubmoduleWalk.IgnoreSubmoduleMode;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.nqm.model.FileStatus;
import org.nqm.utils.GisStringUtils;
import org.nqm.utils.StdOutUtils;
Expand Down Expand Up @@ -111,6 +120,14 @@ private static String statusFull(Repository repo, Status status, String localBra
status.getConflicting().stream().forEach(computeStatus.apply(CONFLICT));
status.getUntrackedFolders().stream().forEach(computeStatus.apply(UNTRACKED_DIRS));

var diff = new DiffFormatter(new ByteArrayOutputStream());
var revlist = new RevWalk(repo);

var rev0 = revlist.next().getId();
var rev1 = revlist.next().getId();
var diffs = diff.scan(rev0, rev1);
System.out.println("\u001B[33m diffs = '%s' \u001B[0m".formatted(diffs));

statusByFiles.forEach((k, v) -> result.append(GisStringUtils.NEWLINE)
.append(" ")
.append(FileStatus.toPrint(k, v)));
Expand Down

0 comments on commit fb7e3a3

Please sign in to comment.