Skip to content

Commit

Permalink
Commit V 0.3
Browse files Browse the repository at this point in the history
add license and preview image
add IVsFileChangeEvents to monitor solution folder change
  • Loading branch information
yysun committed May 28, 2010
1 parent 979d473 commit 86eaf47
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 314 deletions.
8 changes: 8 additions & 0 deletions BasicSccProvider.csproj
Expand Up @@ -85,9 +85,17 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="License.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Resources\Images_24bit.bmp" />
<Content Include="Resources\Images_32bit.bmp" />
<Content Include="Resources\SccGlyphs.bmp" />
<Content Include="solution explorer.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<None Include="source.extension.vsixmanifest" />
<None Include="Resources\Product.ico" />
</ItemGroup>
Expand Down
70 changes: 7 additions & 63 deletions GitFileStatusTracker.cs
Expand Up @@ -11,8 +11,6 @@ public class GitFileStatusTracker
{
private RepositoryStatus repositoryStatus;
private Uri workingFolderUri;
//private FileSystemWatcher watcher;
//private IgnoreRules ignoreRules;

public GitFileStatusTracker()
{
Expand All @@ -23,47 +21,18 @@ public void Open(string workingFolder)
{
Close();

if (!string.IsNullOrEmpty(workingFolder))
if (!string.IsNullOrEmpty(workingFolder) && Repository.IsValid(workingFolder))
{
try
{
var repo = new Repository(workingFolder);
this.repositoryStatus = repo.Status;
this.workingFolderUri = new Uri(repo.WorkingDirectory+"\\");
//this.ignoreRules = new IgnoreRules(Path.Combine(repo.WorkingDirectory, GitSharp.Core.Constants.GITIGNORE_FILENAME));

//this.watcher = new FileSystemWatcher(workingFolder + "\\" + GitSharp.Core.Constants.DOT_GIT); //?
////this.watcher = new FileSystemWatcher(workingFolder); //?

//this.watcher.NotifyFilter = NotifyFilters.LastWrite;
//this.watcher.EnableRaisingEvents = true;
//this.watcher.Changed += new FileSystemEventHandler(watcher_Changed);
}
catch
{
}
}

}

private DateTime TimeFired;
public event EventHandler OnGitRepoChanged;
private object locker = new object();

void watcher_Changed(object sender, FileSystemEventArgs e)
{
lock (locker)
{
double delta = DateTime.Now.Subtract(TimeFired).TotalMilliseconds;
if (delta < 500) return;

//if (IsIgnoredFile(e.FullPath)) return;

this.repositoryStatus.Update();
if (OnGitRepoChanged != null) OnGitRepoChanged(this, EventArgs.Empty);

TimeFired = DateTime.Now;
}
}

public bool HasGitRepository
Expand All @@ -76,39 +45,8 @@ public void Close()
if (this.repositoryStatus != null) this.repositoryStatus.Repository.Close();
this.repositoryStatus = null;
this.workingFolderUri = null;
//this.ignoreRules = null;

//if (this.watcher != null)
//{
// this.watcher.Changed -= new FileSystemEventHandler(watcher_Changed);
// this.watcher.Dispose();
//}

}

//private bool IsIgnoredFile(string fileName)
//{
// try
// {
// if (Directory.Exists(fileName))
// {
// return this.ignoreRules.IgnoreDir(this.repositoryStatus.Repository.WorkingDirectory, fileName);
// }
// else if (File.Exists(fileName))
// {
// return this.ignoreRules.IgnoreDir(this.repositoryStatus.Repository.WorkingDirectory,
// Path.GetDirectoryName(fileName)) ||
// this.ignoreRules.IgnoreFile(this.repositoryStatus.Repository.WorkingDirectory, fileName);
// }
// else
// return true;
// }
// catch
// {
// return false;
// }
//}

public GitFileStatus GetFileStatus(string fileName)
{
if (!HasGitRepository || string.IsNullOrEmpty(fileName) || !File.Exists(fileName))
Expand Down Expand Up @@ -137,6 +75,12 @@ public GitFileStatus GetFileStatus(string fileName)
return GitFileStatus.Trackered;
}
}

internal void Update()
{
if (this.repositoryStatus!=null)
this.repositoryStatus.Update();
}
}

public static class HashSetExt
Expand Down
31 changes: 31 additions & 0 deletions License.txt
@@ -0,0 +1,31 @@
Microsoft Public License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Definitions

The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

A "contribution" is the original software, or any additions or changes to the software.

A "contributor" is any person that distributes its contribution under this license.

"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations

(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
221 changes: 0 additions & 221 deletions Overview.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Expand Up @@ -22,7 +22,7 @@
[assembly: AssemblyTitle("Git Source Control Provider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Yiyisun@hotmail.com")]
[assembly: AssemblyProduct("Git Source Control Provider")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
Expand Down

0 comments on commit 86eaf47

Please sign in to comment.