nodejs-tw / ama

Ask me anything!
MIT License
31 stars 1 forks source link

想請教nodegit的問題,在gitlab上面有錯誤訊息,推commit推不上去 #15

Open michael34435 opened 7 years ago

michael34435 commented 7 years ago

目的

我希望用nodegit做cherry-pick工具

使用的工具

macOS 10.12.1 node.js 7.1.0 --harmony-async-await nodegit 0.16.0

操作流程

透過nodegit的cherry-pick功能成功建立了commit,並且送到remote端做push的動作

嘗試過的解法

嘗試用connect先連線但是還是沒有效果

程式碼

程式碼

const repo = await Git.Repository.open(process.cwd())
const remote = await repo.getRemote('origin')
const current = await repo.getCurrentBranch()
await remote.push(
  [`${current.name()}:${current.name()}`],
  {
    callbacks: {
      certificateCheck: () => 1,
      credentials: (url) => {
        if (url.indexOf('http') === -1) {
          return Git.Cred.sshKeyFromAgent(USERNAME)
        } else {
          return Git.Cred.userpassPlaintextNew(USERNAME, PASSWORD)
        }
      }
    }
  }
)

錯誤

Error: Unexpected HTTP status code: 411
michael34435 commented 7 years ago

問題看來已經確定了,目前是判斷說nodegit那裡只要碰到http protocol就會reject