Ejemplo n.º 1
0
		public override Annotation[] GetAnnotations (FilePath repositoryPath)
		{
			var repository = GetRepository (repositoryPath);
			RevCommit hc = GetHeadCommit (repository);
			if (hc == null)
				return new Annotation [0];

			var git = new NGit.Api.Git (repository);
			var result = git.Blame ().SetFollowFileRenames (true).SetFilePath (repository.ToGitPath (repositoryPath)).Call ();
			result.ComputeAll ();

			List<Annotation> list = new List<Annotation> ();
			for (int i = 0; i < result.GetResultContents ().Size (); i++) {
				var commit = result.GetSourceCommit (i);
				var author = result.GetSourceAuthor (i);
				if (commit != null && author != null) {
					string name = string.Format ("{0} <{1}>", author.GetName (), author.GetEmailAddress ());
					var commitTime = new DateTime (1970, 1, 1).AddSeconds (commit.CommitTime);
					list.Add (new Annotation (commit.Name, name, commitTime));
				} else {
					list.Add (new Annotation (new string ('0', 20), "<uncommitted>", DateTime.Now));
				}
			}
			return list.ToArray ();
		}