2016-07-08 2 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 git check-ref-format에 전화를 랩 : 규칙 중 하나 이후

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

은 다음과 같습니다

을 그들은 적어도 하나의 /을 포함해야합니다. 이것은 heads/, tags/ 등과 같은 카테고리의 존재를 강요하지만 실제 이름은 제한되지 않습니다.

tags/xxx으로 시작하는 태그 이름으로 테스트 해보십시오.

이것이 작동하면 tag_name의 유효성이 어떻게되는지에 대한 버그 일 수 있습니다.

+0

감사합니다,하지만 여전히 같은 ➜/tmp를 컬이다 -X POST -d @ body.json https://mygitlabserver.com/api/ v3/projects/9733/repository/tags - 헤더 "Content-Type : application/json"-H "개인 토큰 : sNW8AGtLMdSGAJiGQ-gV" { "message": "태그 이름이 잘못되었습니다"} % ➜/tmp cat body .json { "message": null, "name": "tags/v1.0.0" 나는 이것이 당신이 나에게 시도해달라고 부탁 한 것이라고 생각하니? 그렇지 않다면 정교하게하십시오 \ –

+0

@PramodSetlur 정확한 git 명령을보기 위해 https://github.com/gitlabhq/gitlabhq/blob/91fa250038e9182988319f088fb84741b6e2efc9/lib/gitlab/git_ref_validator.rb를 수정하여 더 많은 추적을 추가하십시오. 실행됩니다. – 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