Programing

BitBucket에서 이전 커밋의 전체 소스에 액세스하는 방법은 무엇입니까?

lottogame 2020. 4. 22. 08:07
반응형

BitBucket에서 이전 커밋의 전체 소스에 액세스하는 방법은 무엇입니까?


흐름에 대해이 질문을 싫어하지만 내 인생에서 새로운 Bit Bucket 형식의 이전 커밋 소스에 액세스하는 방법에 대한 문서를 찾을 수 없습니다. 더 이상 가능합니까? 너무 좌절!


Mercurial / Git 클라이언트를 사용하지 않고 BitBucket 웹 인터페이스를 통해 이전 버전을 다운로드하려고합니다.

관련 질문을 확인하십시오 . 의견에 따르면 누군가 그렇게 할 방법이 없다고 말합니다. 다행히도 그것은 사실이 아닙니다.

BitBucket 프로젝트 페이지를 탐색하여 임의 버전을 다운로드 할 수있는 링크가 없습니다. 다음과 같은 형식으로 특정 태그를 다운로드 할 수있는 링크가 있습니다.

https://bitbucket.org/owner/repository/get/v0.1.2.tar.gz

그러나 위의 URL을 약간 조정하여 커밋 해시로 태그 이름을 변경하면 다음과 같습니다.

https://bitbucket.org/owner/repository/get/A0B1C2D.tar.gz

실제로 특정 버전을 다운로드 할 수 있습니다.

에서 언급 한 바와 같이 락카 분노 교체, 코멘트에 .tar.gz의해 .zip너무 작품.


GitHub에서 할 수있는 것처럼 이전 커밋 코드를 탐색 할 수 있는지 알아 내려고 노력 중입니다. 나는 여기에서 찾은 정보를 사용했고 URL을 찾은 후에 실제로 오래된 커밋 코드를 탐색하는 방법을 찾았습니다.

코드를 탐색 할 때 URL은 다음과 같습니다.

https://bitbucket.org/user/repo/src/

그리고 끝에 다음과 같이 commit hash를 추가하면 :

https://bitbucket.org/user/repo/src/a0328cb

해당 커밋 시점에서 코드를 찾아 볼 수 있습니다. 커밋을 직접 선택하기위한 드롭 다운 상자가없는 이유를 이해하지 못합니다.이 기능은 이미 있습니다. 이상한.


1 단계

1 단계


2 단계

2 단계


3 단계

3 단계


4 단계

4 단계


마지막 단계

마지막 단계


이 답변 중 어느 것도 정확하게 작동하지 않은 사람이 내 보트에있는 경우를 대비하여 여기 내가 한 일이 있습니다.

아마도 우리의 사내 Bitbucket 서버는 대부분의 것과 약간 다르게 설정되지만 마스터 브랜치에서 파일을보기 위해 일반적으로 사용하는 URL은 다음과 같습니다.

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse

드롭 다운 메뉴에서 master와 다른 지점을 선택하면 다음과 같이 나타납니다.

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=refs%2Fheads%2F<BRANCH_NAME>

그래서 나는 이것을 시도했고 효과가 있었다 :

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>

이제 커밋 당시와 마찬가지로 전체 리포지토리를 찾아 볼 수 있습니다.


몇 년 전에 큰 답변. 이제 Bitbucket이 더 쉬워졌습니다.

Rudy Matela의 답변에서 언급 한대로 다운로드하려는 커밋에 태그를 지정하십시오.

그런 다음 다운로드로 이동하여 "태그"탭을 클릭하면 여러 다운로드 옵션이 제공됩니다.

태그 다운로드


기록을 위해 다음과 같이 URL을 둘러 볼 수도 있습니다.

최신 소스를 탐색 할 때 다음과 같은 것이 있습니다. https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master

커밋 해시를 변경하고 GET 매개 변수를 제거하십시오. https://bitbucket.org/my/repo/src/wantedcommithash/my.file

위의 +1 @Hein A. Grønnestad로 가십시오 : GUI에서 왜 아무것도 사용하지 않는지 궁금합니다.


  1. 가장 쉬운 방법은 해당 커밋을 클릭하고 해당 커밋에 태그를 추가하는 것입니다. 이 커밋에 'last_commit'태그를 포함 시켰습니다.

  2. 비트 버킷에서 측면 탐색 메뉴의 왼쪽 모서리에있는 다운로드로 이동하는 것보다. 왼쪽에서 다운로드를 클릭하십시오

  3. 탐색 바에서 태그를 클릭하고 UI에서 zip을 다운로드하십시오. 태그를 찾고 zip을 다운로드하십시오

?until=<sha-of-commit>파일 이름 뒤에 URL 을 추가하여 특정 커밋까지 파일의 소스를 볼 수 있습니다 .


너무 늦었지만 API 2.0을 사용하면 할 수 있습니다.

명령 줄에서

curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>

또는 PHP에서 :

$data = json_decode(file_get_contents("https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>", true));

그런 다음 가장 최근의 커밋에서 가장 오래된 커밋까지 파일 히스토리가 있습니다.

{
"pagelen": 50,
"values": [
    {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<hash>/<path_file>"
        },
        "meta": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD>/<path_file>?format=meta"
        },
        "history": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD>/<path_file>"
        }
      },
      "commit": {
        "hash": "<HEAD>",
        "type": "commit",
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD>"
          },
          "html": {
            "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD>"
          }
        }
      },
      "attributes": [],
      "path": "<path_file>",
      "type": "commit_file",
      "size": 31
    },
    {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>"
        },
        "meta": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>?format=meta"
        },
        "history": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD~1>/<path_file>"
        }
      },
      "commit": {
        "hash": "<HEAD~1>",
        "type": "commit",
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD~1>"
          },
          "html": {
            "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD~1>"
          }
        }
      },
      "attributes": [],
      "path": "<path_file>",
      "type": "commit_file",
      "size": 20
    }
  ],
  "page": 1
}

여기서 values> links> self당신이 그것을 검색 할 수 있습니다 역사의 순간에 파일 제공 curl <link>또는 file_get_contents(<link>).

결국 명령 행에서 다음을 사용하여 필터링 할 수 있습니다.

 curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>?fields=values.links.self

PHP에서는 foreach배열 에서 루프를 만듭니다 $data.

참고 : <path_file>가있는 경우 /로 변환해야합니다 %2F.

다음 문서를 참조하십시오 : https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D

참고 URL : https://stackoverflow.com/questions/14528344/how-to-access-full-source-of-old-commit-in-bitbucket

반응형