JGIT with LFS: Archive does not has actual files [message #1748717] |
Sun, 27 November 2016 19:00 |
Afroz Shaik Messages: 3 Registered: November 2016 |
Junior Member |
|
|
JGIT/LFS Team,
We are using JGIT in our project. We recently observed that there is LFS support so I am evaluating this.
I have been able to install GIT LFS locally and configured LFS to track some files. I also committed .gitattributes file.
A. I was able to checkout a commit/branch and can confirm I am able to extract LFS files via JGIT [with a caveat though]. I did not have to change any code in our previous checkout code.
However when I am trying to build a zip file at the same commit, I am ONLY getting pointer files.
Am I missing something?
The git core "archive" command does in fact seem to insert the final object pointed by pointer file.
B. I also want to know if I need to have GIT LFS client installed for JGIT LFS to work. This is because my "jgit checkout" only works if GIT LFS client is installed. Is there some config I need to point to make it work without GIT LFS client.
Let us say I am using a GIT server where it stores objects in a special file store, what is config needed to make it look into this file store.
Are there any examples I can use. Any help is appreciated.
Thanks so much in advance.
I do not get any error.
Best Regards
Afroz Shaik
---------------------
String repoDir = "C:/Users/a0216021/gerrit/test/lfstest/.git";
String lfsarchive = "C:/Users/a0216021/gerrit/test/lfsarchive/";
String outputFile = lfsarchive + File.separator + "lfstest.zip";
ArchiveFormats.registerAll();
try (FileOutputStream out = new FileOutputStream(outputFile)) {
String commitId = "0dd5ce1f29541cd520b0ac810f88cbfc2d93c5a4";
log.info("generateArchive method Repo Dir: {}", repoDir);
//an existing repository
File repoDirObj = new File(repoDir);
try (Repository myRepo = new FileRepositoryBuilder()
.setGitDir(repoDirObj)
.readEnvironment()
.findGitDir().build()) {
git = new Git(myRepo);
ObjectId objectId = myRepo.resolve(commitId);
if (objectId != null) {
log.info("Resolved commitId: {} ", objectId.getName());
}
git.archive().setTree(objectId).setFormat("zip")
.setOutputStream(out).call();
}
}
ArchiveFormats.unregisterAll();
[Updated on: Mon, 28 November 2016 20:02] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03029 seconds