Skip to content

Commit

Permalink
Built in Git: cannot commit deleted files #394
Browse files Browse the repository at this point in the history
  • Loading branch information
aeberhart committed Jul 16, 2024
1 parent 210bd4a commit c15e93b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.microprofile.config.ConfigProvider;
Expand All @@ -27,8 +29,13 @@ public Void run(List args) throws Exception {
if (message == null || paths == null || paths.isEmpty())
throw new IllegalArgumentException("Arguments required: $gitCommit(message, [paths])");
try (Git git = new Git(new FileRepository(services.getTenantHome() + "/.git"))) {
Status status = git.status().call();
Set<String> missing = status.getMissing();
for (Object s : paths)
git.add().addFilepattern("" + s).call();
if (missing.contains(s))
git.rm().addFilepattern("" + s).call();
else
git.add().addFilepattern("" + s).call();
git.commit().setMessage(message).call();
git.push()
.setCredentialsProvider(
Expand Down

0 comments on commit c15e93b

Please sign in to comment.