Skip to content

Commit

Permalink
Apply some IDE suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
centic9 committed Dec 15, 2024
1 parent 2db26cd commit bd9b92a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.transport.SshTransport;
import org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory;
import org.eclipse.jgit.transport.ssh.jsch.OpenSshConfig;
import org.eclipse.jgit.util.FS;

import java.util.Map;
Expand All @@ -32,10 +30,6 @@ public class FetchRemoteCommitsWithSshAuth {
public static void main(String[] args) throws GitAPIException {

final SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
@Override
protected void configure(OpenSshConfig.Host host, Session session) {
}

@Override
protected JSch createDefaultJSch(FS fs) throws JSchException {
JSch defaultJSch = super.createDefaultJSch(fs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;


Expand Down Expand Up @@ -95,7 +94,7 @@ public static void main(String[] args) throws IOException, GitAPIException {
private static void createCommit(Repository repository, Git git, String fileName, String content) throws IOException, GitAPIException {
// create the file
File myFile = new File(repository.getDirectory().getParent(), fileName);
Files.write(myFile.toPath(), content.getBytes(StandardCharsets.UTF_8));
Files.writeString(myFile.toPath(), content);

// run the add
git.add()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void main(String[] args) throws IOException, GitAPIException {

// write some initial text to it
String initialText = "Initial Text";
System.out.println("Writing text [" + initialText + "] to file [" + tempFile.toString() + "]");
System.out.println("Writing text [" + initialText + "] to file [" + tempFile + "]");
Files.write(tempFilePath, initialText.getBytes());

// add the file and commit it
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/dstadler/jgit/unfinished/UpdateIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
limitations under the License.
*/

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.dstadler.jgit.helper.CookbookHelper;
import org.eclipse.jgit.api.Git;
Expand All @@ -33,6 +28,11 @@
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Repository;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Set;

/**
* Note: This snippet is not done and likely does not show anything useful yet
*
Expand Down Expand Up @@ -78,7 +78,7 @@ private static class AssumeChangedCommand extends GitCommand<String> {
}

@Override
public String call() throws GitAPIException {
public String call() {
try {
DirCache index = repo.lockDirCache();
DirCacheEntry entry = index.getEntry(fileName);
Expand Down

0 comments on commit bd9b92a

Please sign in to comment.