c# - Unable to push to GitLab endpoint LibGit2Sharp -


i attempting initialize , push initial commit gitlab repository using libgit2sharp.

if (!directory.exists("d:\\gitrepos\\" + repositoryname))         {             directory.createdirectory("d:\\gitrepos\\" + repositoryname);             file.create("d:\\gitrepos\\" + repositoryname + "\\readme.md").close();         }          repository.init("d:\\gitrepos\\" + repositoryname);          using (var repo = new repository("d:\\gitrepos\\" + repositoryname))         {             repo.index.add("readme.md");             signature author = new signature("user", "user@user.com", datetime.now);             signature committer = author;             repo.commit("initial commit", author, committer);             repo.network.remotes.add("origin", validrepohttpsurl);             remote remote = repo.network.remotes["origin"];              var options = new pushoptions             {                 credentialsprovider = (_url, _user, _cred) =>                     new usernamepasswordcredentials {username = "validuser", password = "validpassword"}             };              string pushrefspec = @"refs/heads/master";             repo.network.push(remote, pushrefspec, options);          }  } 

the repository created , initialized locally without issue. readme file created , added repo index , commit succeeds. when try push commit remote endpoint receive error stating :

"request failed status code: 411"  

if put breakpoint right before push , set http.postbuffer repo following command:

git config http.postbuffer 524288000 

i receive new error when push executes:

failed write chunk footer: connection server terminated abnormally 

i able stand bitbucket git repo , push without issues, seems may problem gitlab.

it looks known issue libgit2sharp based on robertn's comment. https://github.com/libgit2/libgit2sharp/issues/905

i able work around temporarily handling push git cli call.

        process p = new process();         // redirect output stream of child process.         p.startinfo.useshellexecute = false;         p.startinfo.redirectstandardoutput = true;         p.startinfo.workingdirectory = "d:\\gitrepos\\" + repositoryname;         p.startinfo.filename = "git.exe";         p.startinfo.arguments = "push -u origin master";         p.start();          string output = p.standardoutput.readtoend();         p.waitforexit(); 

something note when being run windows service local system call takes 2-3 minutes small commit push. when switched service run domain user immediate. also, works because have ssh , proper keys setup on host, otherwise git prompt username , password. had use ssh url instead of http stated in original question.


Comments