Added more docs and stuff.

This commit is contained in:
Andrew Lalis 2022-04-18 21:39:13 +02:00
parent d16d81209d
commit 4b6df5bf79
3 changed files with 26 additions and 7 deletions

View File

@ -1,2 +1,4 @@
# distribugit # DistribuGit
Tool for performing operations on many git repositories at once. Tool for performing operations on many git repositories at once. It works by cloning a set of repositories, and applying an action to each repository.
The easiest way to use this toolset for automating git operations is to include it as a maven dependency.

View File

@ -166,13 +166,14 @@ public class DistribuGit {
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
new Builder() new DistribuGit.Builder()
.selector(RepositorySelector.from( .selector(RepositorySelector.from(
"https://github.com/andrewlalis/RandomHotbar.git", "https://github.com/andrewlalis/RandomHotbar.git",
"https://github.com/andrewlalis/CoyoteCredit.git", "https://github.com/andrewlalis/CoyoteCredit.git",
"https://github.com/andrewlalis/SignalsAndSystems2021.git" "https://github.com/andrewlalis/SignalsAndSystems2021.git"
)) ))
.action(git -> System.out.println("Cloned!")) .credentials(GitCredentials.ofUsernamePassword("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", ""))
.action(RepositoryAction.ofCommand("/bin/bash", "../../test.sh"))
.statusListener(new StatusListener() { .statusListener(new StatusListener() {
@Override @Override
public void progressUpdated(float percentage) { public void progressUpdated(float percentage) {
@ -184,8 +185,8 @@ public class DistribuGit {
System.out.println("Message: " + message); System.out.println("Message: " + message);
} }
}) })
.strictFail(true) .strictFail(false)
.cleanup(true) .cleanup(false)
.build().doActions(); .build().doActions();
} }
} }

View File

@ -5,5 +5,21 @@ import org.eclipse.jgit.api.Git;
public interface RepositoryAction { public interface RepositoryAction {
void doAction(Git git) throws Exception; void doAction(Git git) throws Exception;
/**
* An action which executes a system command, as handled by
* {@link ProcessBuilder}. Note that the working directory of the command
* is set to the directory of the repository.
* @param command The command to run.
* @return The command action.
*/
static RepositoryAction ofCommand(String... command) {
return git -> {
ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(git.getRepository().getWorkTree());
pb.inheritIO();
Process p = pb.start();
int result = p.waitFor();
if (result != 0) throw new IllegalStateException("Non-zero exit code from script.");
};
}
} }