public void SameInstanceShouldBeEqual() { var repos = new Repository(db); var obj = repos.CurrentBranch.CurrentCommit; Assert.IsTrue(obj == obj); }
public void ShouldBeAbleToReadAuthorDate2() { var repos = new Repository(db); var commit = new Commit(repos, KnownCommit); Assert.AreEqual(_expectedDate, commit.AuthorDate); }
public void RefNameResolution() { var repo = new Repository(db); var master = new Ref(repo, "refs/heads/master"); var previous = new Ref(repo,"refs/heads/master^"); Assert.AreNotEqual(master.Target.Hash, previous.Target.Hash); Assert.AreEqual((master.Target as Commit).Parent.Hash, previous.Target.Hash); }
public void DifferentInstancesShouldntBeEqual() { var repos = new Repository(db); var obj = repos.CurrentBranch.CurrentCommit; var obj2 = repos.CurrentBranch.CurrentCommit.Parent; Assert.IsTrue(obj != obj2); }
public void UpdateBranch() { var repo = new Repository(db); var master = new Branch(repo, "refs/heads/master"); var origin_master = new Branch(repo, "refs/remotes/origin/master"); origin_master.Update(master); Assert.AreEqual(master.CurrentCommit.Hash, origin_master.CurrentCommit.Hash); var remote_head = repo.Refs["refs/remotes/origin/master"]; Assert.AreEqual(master.CurrentCommit.Hash, remote_head.Target.Hash); }
public void ShouldBeAbleToReadAuthorDate() { var expectedDate = new DateTimeOffset(); try { expectedDate = DateTimeOffset.Parse("2005-04-07 15:32:13 -07:00"); } catch (NotImplementedException) { Assert.Ignore("Doesn't pass on Mono because of 'System.NotImplementedException : The requested feature is not implemented.at System.DateTimeOffset.Parse'."); } var repos = new Repository(db); var commit = new Commit(repos, KnownCommit); Assert.AreEqual(expectedDate, commit.AuthorDate); }
public void WriteBlob() { var repo = new Repository(db); { var blob = Blob.CreateFromFile(repo, "Resources/single_file_commit/i-am-a-file"); Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", blob.Hash); Assert.AreEqual(File.ReadAllText("Resources/single_file_commit/i-am-a-file"), blob.Data); var same_blob = new Blob(repo, blob.Hash); Assert.AreEqual(File.ReadAllBytes("Resources/single_file_commit/i-am-a-file"), same_blob.RawData); } { var blob = Blob.Create(repo, "and this is the data in me\r\n\r\n"); Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", blob.Hash); } { var blob = Blob.Create(repo, Encoding.UTF8.GetBytes("and this is the data in me\r\n\r\n")); Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", blob.Hash); } }
/// <summary> /// Create a new Blob containing the contents of the given file. /// </summary> /// <param name="repo"></param> /// <param name="content"></param> /// <returns></returns> public static Blob CreateFromFile(Repository repo, string path) { if (new FileInfo(path).Exists == false) throw new ArgumentException("File does not exist", "path"); return Create(repo, File.ReadAllBytes(path)); }
internal Branch(Repository repo, CoreRef @ref) : this(repo, @ref.Name) { }
public Branch(Repository repo, string name) : base(repo, name) { }
internal Commit(Repository repo, ObjectId id) : base(repo, id) { }
internal Commit(Repository repo, CoreCommit internal_commit) : base(repo, internal_commit.CommitId) { _internal_commit = internal_commit; }
internal Commit(Repository repo, CoreRef @ref) : base(repo, @ref.ObjectId) { }
/// <summary> /// Execute the command. /// </summary> public override void Execute() { var repo = new GitSharp.Core.Repository(new DirectoryInfo(ActualDirectory)); repo.Create(Bare); repo.Config.setBoolean("core", null, "bare", Bare); repo.Config.save(); if (!Quiet) { OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName); OutputStream.Flush(); } Repository = new Repository(repo.Directory.FullName); }
/// <summary> /// Create a new Blob containing the given string data as content. The string will be encoded by the submitted encoding /// </summary> /// <param name="repo"></param> /// <param name="content"></param> /// <returns></returns> public static Blob Create(Repository repo, string content, Encoding encoding) { return Create(repo, encoding.GetBytes(content)); }
internal Leaf(Repository repo, FileTreeEntry entry) : base(repo, entry.Id) { _internal_file_tree_entry = entry; }
internal AbstractObject(Repository repo, ObjectId id) { _repo = repo; _id = id; }
internal Tag(Repository repo, ObjectId id, string name) : base(repo, id) { _name = name; }
internal Tag(Repository repo, CoreTag internal_tag) : base(repo, internal_tag.Id) { _internal_tag = internal_tag; }
internal Tag(Repository repo, CoreRef @ref) : base(repo, @ref.ObjectId) { _name = @ref.Name; }
private string _name; // <--- need the name for resolving purposes only. once the internal tag is resolved, this field is not used any more. #endregion Fields #region Constructors public Tag(Repository repo, string name) : base(repo, name) { _name = name; }
public Index(Repository repo) { _repo = repo; }
/// <summary> /// Create a new Blob containing the given string data as content. The string will be encoded as UTF8 /// </summary> /// <param name="repo"></param> /// <param name="content"></param> /// <returns></returns> public static Blob Create(Repository repo, string content) { return Create(repo, content, Encoding.UTF8); }
internal Blob(Repository repo, ObjectId id) : base(repo, id) { }
/// <summary> /// Create a new Blob containing exactly the bytes given. /// </summary> /// <param name="repo"></param> /// <param name="content"></param> /// <returns></returns> public static Blob Create(Repository repo, byte[] content) { var db = repo._internal_repo; var id = new GitSharp.Core.ObjectWriter(db).WriteBlob(content); return new Blob(repo, id, content); }
internal AbstractObject(Repository repo, string name) { _repo = repo; _id = _repo._internal_repo.Resolve(name); }
public Blob(Repository repo, string hash) : base(repo, hash) { }
internal Tree(Repository repo, CoreTree tree) : base(repo, tree.Id) { _internal_tree = tree; }
internal Blob(Repository repo, ObjectId id, byte[] blob) : base(repo, id) { _blob = blob; }
public Commit(Repository repo, string name) : base(repo, name) { }