All of lore.kernel.org
 help / color / mirror / Atom feed
From: mr.gaffo@gmail.com
To: git@vger.kernel.org
Cc: "mike.gaffney" <mike.gaffney@asolutions.com>
Subject: [PATCH JGit 07/19] implemented the packs file update functionality
Date: Sun, 13 Sep 2009 13:44:23 -0500	[thread overview]
Message-ID: <1252867475-858-8-git-send-email-mr.gaffo@gmail.com> (raw)
In-Reply-To: <1252867475-858-7-git-send-email-mr.gaffo@gmail.com>

From: mike.gaffney <mike.gaffney@asolutions.com>

---
 .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   23 ++++++++++++++++++-
 .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   17 +++++++++-----
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
index 11d183e..25b78c5 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
@@ -1,11 +1,30 @@
 package org.spearce.jgit.lib;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
 import junit.framework.TestCase;
 
+import org.spearce.jgit.util.JGitTestUtil;
+
 public class UpdateDirectoryInfoCacheTest extends TestCase {
+	private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
+	private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
+	private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
 	
-	public void testBase() throws Exception {
-		fail("nyi");
+	public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
+		List<PackFile> packs = new ArrayList<PackFile>();
+		packs.add(new PackFile(TEST_IDX, TEST_PACK));
+		
+		File packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), "tstdata");
+		packsFile.deleteOnExit();
+		
+		String expectedContents = new PacksFileContentsCreator(packs).toString();
+		
+		new UpdateDirectoryInfoCache(packs, packsFile).execute();
+		
+		assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
 	}
 
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
index 2bceb9e..72a315a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
@@ -1,22 +1,27 @@
 package org.spearce.jgit.lib;
 
+import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.List;
 
 public class UpdateDirectoryInfoCache {
 
 	private List<PackFile> packsList;
-	private File infoDirectory;
+	private File infoPacksFile;
 
 	public UpdateDirectoryInfoCache(List<PackFile> packsList,
-			File infoDirectory) {
+									File infoPacksFile) {
 		this.packsList = packsList;
-		this.infoDirectory = infoDirectory;
+		this.infoPacksFile = infoPacksFile;
 	}
 
-	public void execute() {
-//		File objectFile = objectDatabase.
-//		String packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();
+	public void execute() throws IOException {
+		String packsContents = new PacksFileContentsCreator(packsList).toString();
+		FileOutputStream fos = new FileOutputStream(infoPacksFile);
+		fos.write(packsContents.getBytes());
+		fos.close();
 	}
 
 }
-- 
1.6.4.2

  reply	other threads:[~2009-09-13 18:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-13 18:44 [PATCH JGit] Adding update-server-info functionality mr.gaffo
2009-09-13 18:44 ` [PATCH JGit 01/19] adding tests for ObjectDirectory mr.gaffo
2009-09-13 18:44   ` [PATCH JGit 02/19] Create abstract method on ObjectDatabase for accessing the list of local pack files mr.gaffo
2009-09-13 18:44     ` [PATCH JGit 03/19] Add abstract method for updating the object db's info cache Implemented passthrough on Alternate for the update of infocache mr.gaffo
2009-09-13 18:44       ` [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles mr.gaffo
2009-09-13 18:44         ` [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass mr.gaffo
2009-09-13 18:44           ` [PATCH JGit 06/19] added utility for reading the contents of a file as a string mr.gaffo
2009-09-13 18:44             ` mr.gaffo [this message]
2009-09-13 18:44               ` [PATCH JGit 08/19] changed signature to allow a IOException mr.gaffo
2009-09-13 18:44                 ` [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache mr.gaffo
2009-09-13 18:44                   ` [PATCH JGit 10/19] moved test up to a higher level to test actual functionality mr.gaffo
2009-09-13 18:44                     ` [PATCH JGit 11/19] removed unused import mr.gaffo
2009-09-13 18:44                       ` [PATCH JGit 12/19] moved info/packs into a constant mr.gaffo
2009-09-13 18:44                         ` [PATCH JGit 13/19] made the call update the object database's info cache mr.gaffo
2009-09-13 18:44                           ` [PATCH JGit 14/19] pulled out some helper functions that will be useful for other tests mr.gaffo
2009-09-13 18:44                             ` [PATCH JGit 15/19] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory mr.gaffo
2009-09-13 18:44                               ` [PATCH JGit 16/19] added tests for the file based info cache update and made pass mr.gaffo
2009-09-13 18:44                                 ` [PATCH JGit 17/19] added call to update the info refs file mr.gaffo
2009-09-13 18:44                                   ` [PATCH JGit 18/19] Added Copyright Notices mr.gaffo
2009-09-13 18:44                                     ` [PATCH JGit 19/19] changed \r to \n per compliance with real git mr.gaffo
2009-09-15 19:23                   ` [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache Robin Rosenberg
2009-09-15 19:23               ` [PATCH JGit 07/19] implemented the packs file update functionality Robin Rosenberg
2009-09-15 16:13           ` [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass Robin Rosenberg
2009-09-15 15:35         ` [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles Robin Rosenberg
2009-09-15 15:38   ` [PATCH JGit 01/19] adding tests for ObjectDirectory Robin Rosenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1252867475-858-8-git-send-email-mr.gaffo@gmail.com \
    --to=mr.gaffo@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mike.gaffney@asolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.