2016-07-08 16 views
2

こんにちはgitlab apiを使用してプロジェクトにタグを作成しようとしていますが、タグ名が正しくないと言っています。私はgitlab api docのサンプルを使ってみました。ここで gitlab apiタグ作成エラー

は私の試みです:

➜ /tmp curl -X POST -d @body.json https://mygitlabserver.com/api/v3/projects/9733/repository/tags --header "Content-Type:application/json" -H "PRIVATE-TOKEN:sNW8AGtLMdSGAJiGQ-gV" 
{"message":"Tag name invalid"}% 

➜ /tmp cat body.json 
{ 
    "commit": { 
     "author_email": "[email protected]", 
     "author_name": "John Smith", 
     "authored_date": "2012-05-28T04:42:42-07:00", 
     "committed_date": "2012-05-28T04:42:42-07:00", 
     "committer_email": "[email protected]", 
     "committer_name": "Jack Smith", 
     "id": "2695effb5807a22ff3d138d593fd856244e155e7", 
     "message": "Initial commit", 
     "parents_ids": [ 
      "2a4b78934375d7f53875269ffd4f45fd83a84ebe" 
     ] 
    }, 
    "message": null, 
    "name": "v1.0.0", 
    "release": { 
     "description": "Amazing release. Wow", 
     "tag_name": "1.0.0" 
    } 
} 

答えて

1

GiLab API for creating a new tagそれはapp/services/create_tag_service.rb

valid_tag = Gitlab::GitRefValidator.validate(tag_name) 

を呼び出しlib/api/tags.rb

# Create tag 
    # 
    # Parameters: 
    # id (required) - The ID of a project 
    # tag_name (required) - The name of the tag 
    # ref (required) - Create tag from commit sha or branch 
    # message (optional) - Specifying a message creates an annotated tag. 
    # Example Request: 
    # POST /projects/:id/repository/tags 
    post ':id/repository/tags' do 
    authorize_push_project 
    message = params[:message] || nil 
    result = CreateTagService.new(user_project, current_user). 
    execute(params[:tag_name], params[:ref], message, params[:release_description]) 

であり、それlib/gitlab/git_ref_validator.rbで、実際のw

def validate(ref_name) 
     Gitlab::Utils.system_silent(
     %W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name})) 
end 

ルールの一つですので:

彼らは、少なくとも1 /が含まれている必要がありgit check-ref-formatへの呼び出しをラップ。これにより、heads/,tags/などのカテゴリの存在が強制されますが、実際の名前は制限されません。

tags/xxxで始まるタグ名でテストしてみてください。

その場合、tag_nameがどのように検証されるかが不具合になります。

+0

ありがとうございましたが、それはまだ同じ ➜/ tmpのカール-X POST -d @ body.json https://mygitlabserver.com/api/です"メッセージ": "タグ名が無効です"}%➜/ tmp cat body(%)/ tmp cat body(%)/ v3/projects/9733/repository/tags - ヘッダー "Content-Type:application/json" -H "PRIVATE-TOKEN:sNW8AGtLMdSGAJiGQ-gV" .json { "message":null、 "名前": "tags/v1.0.0" これは私が試してみたものですと思いますか? \ –

+0

@PramodSetlur https://github.com/gitlabhq/gitlabhq/blob/91fa250038e9182988319f088fb84741b6e2efc9/lib/gitlab/git_ref_validator.rbを修正してトレースを追加して正確なgitコマンドを確認してください実行されます。 – VonC

+0

APIをホストするボックスにアクセスできません。 :/ –

4

私はそれをこのように動作させました。

これは、POSTリクエストです:

curl -X POST -k -H 'PRIVATE-TOKEN: XXXXXXX' \ 
'https://mygitlabserver.com/api/v3/projects/9733/repository/tags?tag_name=0.0.9&ref=develop' 
+1

私の答えに見られるrefパラメータの良いキャッチ。 +1 – VonC

関連する問題