git - How to push newly created tag using Lib2Gitsharp -


could me push newly created tag using lib2gitsharp? below code creates tag correctly, when push tag gives me "request failed statis code: 401"

    public static bool createtag(string tag,string localrepopath)     {         var repo = new repository(localrepopath);         if (repo == null)         {             console.writeline(datetime.now + "no repository exists in " + localrepopath);             return false;         }         tag t = repo.applytag(tag);         if (t == null)         {             console.writeline(datetime.now + "could not create tag :" + tag);             return false;         }         else             console.writeline(datetime.now + "tag has been created :" + tag);         return true;     }      //push tags     public static bool pushtags(string tag, string localrepopath)     {         try         {             using (repository repo = new repository(localrepopath))             {                 remote remote = repo.network.remotes["origin"];                 repo.network.push(remote, "refs/tags/test1", "refs/tags/test1");              }         }         catch(exception ex)         {             console.writeline(datetime.now + "----#errors in push tag " + tag + " " + ex.message);             return false;         }          return true;     } 

this code works!

    public static bool createtag(string tag,string localrepopath)     {         var repo = new repository(localrepopath);         if (repo == null)         {             console.writeline(datetime.now + "no repository exists in " + localrepopath);             return false;         }         tag t = repo.applytag(tag);         if (t == null)         {             console.writeline(datetime.now + "could not create tag :" + tag);             return false;         }         else             console.writeline(datetime.now + "tag has been created :" + tag);         return true;     }      //push tags     public static bool pushtags(string tag, string localrepopath)     {         try         {             credentials creds = new usernamepasswordcredentials()             {                 username = username,                 password = password             };             credentialshandler ccd = (url, usernamefromurl, types) => creds;             pushoptions options = new pushoptions { credentialsprovider = ccd };             string rfspec = "refs/tags/" + tag;             using (repository repo = new repository(localrepopath))             {                 remote remote = repo.network.remotes["origin"];                 repo.network.push(remote, rfspec, rfspec, options);              }         }         catch(exception ex)         {             console.writeline(datetime.now + "----#errors in push tag " + tag + " " + ex.message);             return false;         }          return true;     } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -