Ejemplo n.º 1
0
        public void SameInstanceShouldBeEqual()
        {
            var repos = new Repository(db);
            var obj = repos.CurrentBranch.CurrentCommit;

            Assert.IsTrue(obj == obj);
        }
Ejemplo n.º 2
0
        public void ShouldBeAbleToReadAuthorDate2()
        {
            var repos = new Repository(db);
            var commit = new Commit(repos, KnownCommit);

            Assert.AreEqual(_expectedDate, commit.AuthorDate);
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        public void DifferentInstancesShouldntBeEqual()
        {
            var repos = new Repository(db);
            var obj = repos.CurrentBranch.CurrentCommit;
            var obj2 = repos.CurrentBranch.CurrentCommit.Parent;

            Assert.IsTrue(obj != obj2);
        }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 /// <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));
 }
Ejemplo n.º 9
0
 internal Branch(Repository repo, CoreRef @ref)
     : this(repo, @ref.Name)
 {
 }
Ejemplo n.º 10
0
 public Branch(Repository repo, string name)
     : base(repo, name)
 {
 }
Ejemplo n.º 11
0
 internal Commit(Repository repo, ObjectId id)
     : base(repo, id)
 {
 }
Ejemplo n.º 12
0
 internal Commit(Repository repo, CoreCommit internal_commit)
     : base(repo, internal_commit.CommitId)
 {
     _internal_commit = internal_commit;
 }
Ejemplo n.º 13
0
 internal Commit(Repository repo, CoreRef @ref)
     : base(repo, @ref.ObjectId)
 {
 }
Ejemplo n.º 14
0
 /// <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);
 }
Ejemplo n.º 15
0
 /// <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));
 }
Ejemplo n.º 16
0
 internal Leaf(Repository repo, FileTreeEntry entry)
     : base(repo, entry.Id)
 {
     _internal_file_tree_entry = entry;
 }
Ejemplo n.º 17
0
 internal AbstractObject(Repository repo, ObjectId id)
 {
     _repo = repo;
     _id = id;
 }
Ejemplo n.º 18
0
 internal Tag(Repository repo, ObjectId id, string name)
     : base(repo, id)
 {
     _name = name;
 }
Ejemplo n.º 19
0
 internal Tag(Repository repo, CoreTag internal_tag)
     : base(repo, internal_tag.Id)
 {
     _internal_tag = internal_tag;
 }
Ejemplo n.º 20
0
 internal Tag(Repository repo, CoreRef @ref)
     : base(repo, @ref.ObjectId)
 {
     _name = @ref.Name;
 }
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
0
 public Index(Repository repo)
 {
     _repo = repo;
 }
Ejemplo n.º 23
0
 /// <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);
 }
Ejemplo n.º 24
0
 internal Blob(Repository repo, ObjectId id)
     : base(repo, id)
 {
 }
Ejemplo n.º 25
0
 /// <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);
 }
Ejemplo n.º 26
0
 internal AbstractObject(Repository repo, string name)
 {
     _repo = repo;
     _id = _repo._internal_repo.Resolve(name);
 }
Ejemplo n.º 27
0
 public Blob(Repository repo, string hash)
     : base(repo, hash)
 {
 }
Ejemplo n.º 28
0
 internal Tree(Repository repo, CoreTree tree)
     : base(repo, tree.Id)
 {
     _internal_tree = tree;
 }
Ejemplo n.º 29
0
 internal Blob(Repository repo, ObjectId id, byte[] blob)
     : base(repo, id)
 {
     _blob = blob;
 }
Ejemplo n.º 30
0
 public Commit(Repository repo, string name)
     : base(repo, name)
 {
 }