Re: [PATCH JGit 07/19] implemented the packs file update functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



söndag 13 september 2009 20:44:23 skrev mr.gaffo@xxxxxxxxx:
> From: mike.gaffney <mike.gaffney@xxxxxxxxxxxxxx>
> 
> ---
>  .../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();
>  	}
>  
>  }

These cleanups could have been done by rewriting the patch set before submitting.

-- robin

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]