Skip to content

Commit 4819b80

Browse files
committed
Revert "Make Tags.Add() accept an ObjectId as its target"
This reverts commit 34c4aac.
1 parent e5f216f commit 4819b80

File tree

3 files changed

+2
-84
lines changed

3 files changed

+2
-84
lines changed

LibGit2Sharp.Tests/TagFixture.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@ public void CanAddALightWeightTagFromSha()
3030
}
3131
}
3232

33-
[Fact]
34-
public void CanAddALightWeightTagFromObjectId()
35-
{
36-
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
37-
using (var repo = new Repository(path.RepositoryPath))
38-
{
39-
Tag newTag = repo.Tags.Add("i_am_lightweight", new ObjectId(commitE90810BSha));
40-
Assert.NotNull(newTag);
41-
Assert.False(newTag.IsAnnotated);
42-
Assert.Equal(commitE90810BSha, newTag.Target.Sha);
43-
}
44-
}
45-
4633
[Fact]
4734
public void CanAddALightWeightTagFromAGitObject()
4835
{
@@ -167,19 +154,6 @@ public void CanAddAnAnnotatedTagFromSha()
167154
}
168155
}
169156

170-
[Fact]
171-
public void CanAddAnAnnotatedTagFromObjectId()
172-
{
173-
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
174-
using (var repo = new Repository(path.RepositoryPath))
175-
{
176-
Tag newTag = repo.Tags.Add("unit_test", new ObjectId(tagTestSha), signatureTim, "a new tag");
177-
Assert.NotNull(newTag);
178-
Assert.True(newTag.IsAnnotated);
179-
Assert.Equal(tagTestSha, newTag.Target.Sha);
180-
}
181-
}
182-
183157
[Fact]
184158
public void CanAddAnAnnotatedTagFromObject()
185159
{
@@ -521,7 +495,6 @@ public void AddTagWithNullTargetThrows()
521495
{
522496
Assert.Throws<ArgumentNullException>(() => repo.Tags.Add("test_tag", (GitObject)null, signatureTim, "message"));
523497
Assert.Throws<ArgumentNullException>(() => repo.Tags.Add("test_tag", (string)null, signatureTim, "message"));
524-
Assert.Throws<ArgumentNullException>(() => repo.Tags.Add("test_tag", (ObjectId)null, signatureTim, "message"));
525498
}
526499
}
527500

LibGit2Sharp/TagCollection.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,6 @@ IEnumerator IEnumerable.GetEnumerator()
6969

7070
#endregion
7171

72-
/// <summary>
73-
/// Creates an annotated tag with the specified name.
74-
/// </summary>
75-
/// <param name = "name">The name.</param>
76-
/// <param name = "targetId">Id of the target object.</param>
77-
/// <param name = "tagger">The tagger.</param>
78-
/// <param name = "message">The message.</param>
79-
/// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
80-
/// <returns></returns>
81-
public virtual Tag Add(string name, ObjectId targetId, Signature tagger, string message, bool allowOverwrite = false)
82-
{
83-
Ensure.ArgumentNotNullOrEmptyString(name, "name");
84-
Ensure.ArgumentNotNull(targetId, "targetId");
85-
Ensure.ArgumentNotNull(tagger, "tagger");
86-
Ensure.ArgumentNotNull(message, "message");
87-
88-
string prettifiedMessage = ObjectDatabase.PrettifyMessage(message);
89-
90-
int res;
91-
using (var objectPtr = new ObjectSafeWrapper(targetId, repo))
92-
using (SignatureSafeHandle taggerHandle = tagger.BuildHandle())
93-
{
94-
GitOid oid;
95-
res = NativeMethods.git_tag_create(out oid, repo.Handle, name, objectPtr.ObjectPtr, taggerHandle, prettifiedMessage, allowOverwrite);
96-
}
97-
98-
Ensure.Success(res);
99-
100-
return this[name];
101-
}
102-
10372
/// <summary>
10473
/// Creates an annotated tag with the specified name.
10574
/// </summary>
@@ -179,30 +148,6 @@ public virtual Tag Add(string name, GitObject target, bool allowOverwrite = fals
179148
return this[name];
180149
}
181150

182-
/// <summary>
183-
/// Creates a lightweight tag with the specified name.
184-
/// </summary>
185-
/// <param name = "name">The name.</param>
186-
/// <param name = "targetId">Id of the target object.</param>
187-
/// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
188-
/// <returns></returns>
189-
public virtual Tag Add(string name, ObjectId targetId, bool allowOverwrite = false)
190-
{
191-
Ensure.ArgumentNotNullOrEmptyString(name, "name");
192-
Ensure.ArgumentNotNull(targetId, "targetId");
193-
194-
int res;
195-
using (var objectPtr = new ObjectSafeWrapper(targetId, repo))
196-
{
197-
GitOid oid;
198-
res = NativeMethods.git_tag_create_lightweight(out oid, repo.Handle, name, objectPtr.ObjectPtr, allowOverwrite);
199-
}
200-
201-
Ensure.Success(res);
202-
203-
return this[name];
204-
}
205-
206151
/// <summary>
207152
/// Creates a lightweight tag with the specified name.
208153
/// </summary>

LibGit2Sharp/TagCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static Tag Add(this TagCollection tags, string name, string objectish, Si
2222

2323
GitObject objectToTag = tags.repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound);
2424

25-
return tags.Add(name, objectToTag.Id, tagger, message, allowOverwrite);
25+
return tags.Add(name, objectToTag, tagger, message, allowOverwrite);
2626
}
2727

2828
/// <summary>
@@ -38,7 +38,7 @@ public static Tag Add(this TagCollection tags, string name, string objectish, bo
3838

3939
GitObject objectToTag = tags.repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound);
4040

41-
return tags.Add(name, objectToTag.Id, allowOverwrite);
41+
return tags.Add(name, objectToTag, allowOverwrite);
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)