Jgit 4.11 иногда ставит все изменения в коммит вместо предоставленного шаблона файла - PullRequest
0 голосов
/ 31 августа 2018

Я проталкиваю изменения через следующий код:

String folderPath = "files/filestoPush/"; String AddPattern = ""; 

List<String> listFiles =new ArrayList<>(); listFiles. add("file1");
AddPattern = folderPath + listFiles.get(0) + ".java" ;
Repository localRepo = new FileRepository(file.getAbsolutePath() + "/.git");
final Git git = new Git(localRepo);
git.add().addFilepattern(AddPattern).call();


String commitid =(git.commit().setMessage("Committed on : " + new Date()).call().getName()).toString();
PullCommand pullCmd = git.pull();


pullCmd.setTransportConfigCallback(new TransportConfigCallback() {

    @Override
    public void configure(Transport transport) {
        SshTransport sshTransport = ( SshTransport )transport;
        sshTransport.setSshSessionFactory( sshSessionFactory );
    }
});
pullCmd.call();
Iterable<PushResult> prs = git.push().setTransportConfigCallback(new TransportConfigCallback() {

    @Override
    public void configure(Transport transport) {
        SshTransport sshTransport = ( SshTransport )transport;
        sshTransport.setSshSessionFactory( sshSessionFactory );
    }
}).call();

Этот код иногда добавляет все изменения в коммит, а не только предоставленный addfilepattern. В этом файле addfilepattern указан относительный путь для одного файла.

...