@@ -100,6 +100,37 @@ public virtual Tag Add(string name, ObjectId targetId, Signature tagger, string
100
100
return this [ name ] ;
101
101
}
102
102
103
+ /// <summary>
104
+ /// Creates an annotated tag with the specified name.
105
+ /// </summary>
106
+ /// <param name = "name">The name.</param>
107
+ /// <param name = "target">The target <see cref="GitObject"/>.</param>
108
+ /// <param name = "tagger">The tagger.</param>
109
+ /// <param name = "message">The message.</param>
110
+ /// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
111
+ /// <returns></returns>
112
+ public virtual Tag Add ( string name , GitObject target , Signature tagger , string message , bool allowOverwrite = false )
113
+ {
114
+ Ensure . ArgumentNotNullOrEmptyString ( name , "name" ) ;
115
+ Ensure . ArgumentNotNull ( target , "target" ) ;
116
+ Ensure . ArgumentNotNull ( tagger , "tagger" ) ;
117
+ Ensure . ArgumentNotNull ( message , "message" ) ;
118
+
119
+ string prettifiedMessage = ObjectDatabase . PrettifyMessage ( message ) ;
120
+
121
+ int res ;
122
+ using ( var objectPtr = new ObjectSafeWrapper ( target . Id , repo ) )
123
+ using ( SignatureSafeHandle taggerHandle = tagger . BuildHandle ( ) )
124
+ {
125
+ GitOid oid ;
126
+ res = NativeMethods . git_tag_create ( out oid , repo . Handle , name , objectPtr . ObjectPtr , taggerHandle , prettifiedMessage , allowOverwrite ) ;
127
+ }
128
+
129
+ Ensure . Success ( res ) ;
130
+
131
+ return this [ name ] ;
132
+ }
133
+
103
134
internal static string PrettifyMessage ( string message )
104
135
{
105
136
var buffer = new byte [ NativeMethods . GIT_PATH_MAX ] ;
@@ -124,6 +155,30 @@ public virtual Tag Create(string name, string target, Signature tagger, string m
124
155
return this . Add ( name , target , tagger , message , allowOverwrite ) ;
125
156
}
126
157
158
+ /// <summary>
159
+ /// Creates a lightweight tag with the specified name.
160
+ /// </summary>
161
+ /// <param name = "name">The name.</param>
162
+ /// <param name = "target">The target <see cref="GitObject"/>.</param>
163
+ /// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
164
+ /// <returns></returns>
165
+ public virtual Tag Add ( string name , GitObject target , bool allowOverwrite = false )
166
+ {
167
+ Ensure . ArgumentNotNullOrEmptyString ( name , "name" ) ;
168
+ Ensure . ArgumentNotNull ( target , "target" ) ;
169
+
170
+ int res ;
171
+ using ( var objectPtr = new ObjectSafeWrapper ( target . Id , repo ) )
172
+ {
173
+ GitOid oid ;
174
+ res = NativeMethods . git_tag_create_lightweight ( out oid , repo . Handle , name , objectPtr . ObjectPtr , allowOverwrite ) ;
175
+ }
176
+
177
+ Ensure . Success ( res ) ;
178
+
179
+ return this [ name ] ;
180
+ }
181
+
127
182
/// <summary>
128
183
/// Creates a lightweight tag with the specified name.
129
184
/// </summary>
0 commit comments