[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [egit-dev] Using the Java API to commit files to a repo
|
Hi Graham,
Why not using JGit porcelain API from org.eclipse.jgit.api? I should
be easier as the classes have a large number of accompanying tests
which can serve as guide on how use the them.
Cheers,
Tomek
On Tue, May 7, 2013 at 4:28 PM, graham etherington (TSL)
<graham.etherington@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
> I'm trying to use the org.eclipse.egit.github.core Java API.
> I have a repo that I own and want to use the API to take a given file (an
> updated version of something already in the repo) and then commit the file
> to the repo so that it replaces the original version.
> I was hoping if someone might give me some clues as to what classes and
> methods I should be using here.
>
> I've looked through the API docs and created some code that I've
> reproduced below as a start. It throws the error "Error with 'tree' field
> in Commit resource", although I never really expected it to run.
>
>
>
> public void makeConnection() throws IOException
> {
> client.setCredentials("smith", "password");
>
> RepositoryService service = new RepositoryService(client);
>
>
>
> IRepositoryIdProvider repoId = new RepositoryId("smith","test");
> Repository repo = service.getRepository(repoId);
>
>
> CommitFile f = new CommitFile();
> f.setFilename("file.txt");
>
> List<CommitFile> filesToCommit = new ArrayList<CommitFile>();
> filesToCommit.add(f);
>
>
> Commit c = new Commit();
> CommitUser cUser = new CommitUser();
> cUser.setName("smith");
> c.setAuthor(cUser);
> c.setMessage("Testing commit");
>
>
> RepositoryCommit rc = new RepositoryCommit();
> User user = new User();
> user.setName("smith");
> rc.setAuthor(user);
> rc.setFiles(filesToCommit);
> rc.setCommit(c);
>
>
> DataService ds = new DataService(client);
> ds.createCommit(repoId, c);
>
> }
>
>
> I'm not quite sure if I'm on the right track, but was hoping if someone
> might point me in the right direction, or give me some sample code that
> might see me on my way.
>
>
> Many thanks,
> Graham
>
>
> _______________________________________________
> egit-dev mailing list
> egit-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/egit-dev