2017-10-06 106 views
1

我是使用下面的命令的新手。我在git bash中運行了這個命令,但無法創建標記。使用curl命令進行git發佈

curl -s -k -X POST -H "Content-Type:application/json" "https://github.com/XXXXXX/custom-component/releases?1.2," -d '{ "user" : { 'email' : 'XXXXXXX', 'password' : 'XXXXX'} ,"tag_name": "1.2.1", "target_commitish": "master", "name": "1234", "body": "Release of version 1234", "draft": false, "prerelease": false}' -b cookie 

執行上面的命令後,我無法找到我的資料庫

任何改變我的輸出會喜歡一些HTML輸出

<!DOCTYPE html> 
     <html> 
      <head> 
     <meta http-equiv="Content-type" content="text/html; charset=utf-8"> 
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; b-uri 'self'; connect-src 'self'; form-action 'self'; img-src data:; script-srself'; style-src 'unsafe-inline'"> 
<meta content="origin" name="referrer"> 
<title>Oh no &middot; GitHub</title> 
<style type="text/css" media="screen"> 
    body { 
    background-color: #f1f1f1; 
    margin: 0; 
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
    } 

    .container { margin: 50px auto 40px auto; width: 600px; text-align: cen; } 

    a { color: #4183c4; text-decoration: none; } 
    a:hover { text-decoration: underline; } 

    h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-wei: 100; margin: 0px; text-shadow: 0 1px 0 #fff; } 
    p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } 

    ul { list-style: none; margin: 25px 0; padding: 0; } 
    li { display: table-cell; font-weight: bold; width: 1%; } 

    .logo { display: inline-block; margin-top: 35px; } 
    .logo-img-2x { display: none; } 
    @media 
    only screen and (-webkit-min-device-pixel-ratio: 2), 
    only screen and ( min--moz-device-pixel-ratio: 2), 
    only screen and ( -o-min-device-pixel-ratio: 2/1), 
    only screen and (  min-device-pixel-ratio: 2), 
    only screen and (    min-resolution: 192dpi), 
    only screen and (    min-resolution: 2dppx) { 
    .logo-img-1x { display: none; } 
    .logo-img-2x { display: inline-block; } 
    } 

    #suggestions { 
    margin-top: 35px; 
    color: #ccc; 
+0

我懷疑這個格式不正確JSON是原因。 (JSON只有雙引號,從來沒有單引號)。但是你能否粘貼命令輸出? (當然,看完後一個更多的時間,單引號打破了'-d'說法,所以你總得去解決它) – Arount

+0

@Arount它像一些HTML輸出 – Abinaya

+0

如果我改變api.github.com獲得錯誤如**「消息」:「未找到」,**如何發送請求? – Abinaya

回答

0

首先,你應該使用api.github.com。其次,您需要將Authorization token傳遞到您的標題中。例如。

curl -v -H "Authorization: token TOKEN" https://api.github.com/repos/octodocs-test/test 

您可以在your personal access token page上找到您的個人訪問令牌。如果你沒有一個,你可以create之一。


因此您的命令看起來可能:

curl -v -s \ 
    -H "Authorization: token xxxxxxxxx" \ 
    -H "Content-Type:application/json" \ 
    "https://api.github.com/repos/:owner/:repo/releases" \ 
    -d '{ "user" : { "email" : "XXXXXXX", "password" : "XXXXX"}, "tag_name": "1.2.1", "target_commitish": "master", "name": "1234", "body": "Release of version 1234", "draft": false, "prerelease": false}' 

參見:GitHub API v3 | GitHub Developer Guide

檢查在REST API v3 Releases docs page的可用版本相關的端點,例如:

  • 通過標籤名獲得釋放:GET /repos/:owner/:repo/releases/tags/:tag
  • 創建發佈:POST /repos/:owner/:repo/releases

參見:How to use Github Release API to make a release without source code?