본문 바로가기

AOSP

다른 작업환경에서 replacement 패치 업로드하기 ('no branches ready for upload' 해결하기)



얼마 전 AOSP에 작은 패치를 하나 올리다가 겪게 된 일입니다.

리뷰 서버에 패치를 업로드 한 후, 홀가분한 마음으로 출근했습니다.

그런데 아뿔싸 -_- 리뷰어로부터 몇 부분 수정 요청이 들어와 있더군요. 그것도 제가 집에서 나온지 한 이십분 뒤에...ㅠㅠ


뭐, 사실 집에 다시 돌아가서 패치를 다시 올려도 상관은 없었지만, 그래도 기왕 패치 올리는거 빨리 올려버리고 싶었습니다.

그래서 이래저래 삽질 좀 하다가, 방법을 찾게 되어 여기에 정리해둡니다.


현재 저장소에 최종 작업한 패치 다운로드


작업을 진행하기 전에, 현재 저장소에 최종 패치를 적용하는 것부터 시작합니다.

패치 다운로드는 repo download 명령으로 수행할 수 있습니다. 업로드한 패치 내용 중 'Download' 부분을 보시면 다운로드를 위한

명령어가 표시되어 있는 것을 확인할 수 있습니다. 아래는 명령어의 한 예를 보여줍니다.


패치를 다운로드하기 위한 명령어

명령어를 실행하면 다음과 같이 패치 내용이 다운로드 되는 것을 확인할 수 있습니다.


AndromacPro:docs kunny$ repo download platform/frameworks/base 68220/3
remote: Counting objects: 21570, done
remote: Finding sources: 100% (8/8)
remote: Getting sizes: 100% (7/7)
remote: Compressing objects: 100% (2653/2653)
remote: Total 8 (delta 0), reused 8 (delta 0)
Unpacking objects: 100% (8/8), done.
From https://android.googlesource.com/platform/frameworks/base
Fixed Drag-and-Drop sample code
 * branch            refs/changes/20/68220/3 -> FETCH_HEAD
Note: checking out 'a2646c66a03081e6f87434ae1c3a0394bad478d1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at a2646c6... Fixed Drag-and-Drop sample code


이제, 이 내용을 임시로 저장해 두어야 합니다. 변경사항을 저장하기 위해 새 브랜치를 하나 만들어줍니다. 아래는 'dnd_base' 라는 이름으로 브랜치를 만들어 주었습니다. 


AndromacPro:docs kunny$ git checkout -b dnd_base

Switched to a new branch 'dnd_base'


이제 패치 업로드를 위해 프로젝트를 만들어줄 차례입니다. repo start 명령으로 프로젝트를 생성한 후, git reset 명령어를 사용하여 다운로드한 변경사항을 현재 프로젝트로 불러옵니다. 이것으로 패치를 작성하기 위한 모든 준비가 끝났습니다. 이제부터는 수정할 것만 신경쓰면 됩니다.


AndromacPro:docs kunny$ repo start dnd_proj .

AndromacPro:docs kunny$ git reset --hard dnd_base

HEAD is now at a2646c6 Fixed Drag-and-Drop sample code


수정이 완료되었다면 평소와 마찬가지로 git commit --amend 옵션으로 replacement patch를 커밋합니다.


AndromacPro:docs kunny$ git add -A

AndromacPro:docs kunny$ git commit --amend

[dnd_proj 6ebb845] Fixed Drag-and-Drop sample code

 1 file changed, 46 insertions(+), 58 deletions(-)


마지막으로 repo upload를 수행하여 업로드하면 패치가 정상적으로 replacement patch로 업로드 된 것을 확인할 수 있습니다.


AndromacPro:docs kunny$ repo upload

Upload project frameworks/base/ to remote branch master:

  branch dnd_proj ( 1 commit, Tue Oct 29 23:32:16 2013 +0900):

         130e1294 Fixed Drag-and-Drop sample code

to https://android-review.googlesource.com/ (y/N)? y

Counting objects: 15, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (8/8), done.

Writing objects: 100% (8/8), 1.18 KiB, done.

Total 8 (delta 7), reused 0 (delta 0)

remote: Resolving deltas: 100% (7/7)

remote: Processing changes: updated: 1, done

To https://android-review.googlesource.com/p/platform/frameworks/base

 * [new branch]      dnd_proj -> refs/for/master


----------------------------------------------------------------------

[OK    ] frameworks/base/ dnd_proj


아래 URL이 이 글을 작성할 때 작성했던 패치의 리뷰사이트 주소입니다. 중간에 삽질을 몇번 하느라(...)좀 히스토리가 이상하긴 하지만,

Patch set 2번까지 업로드한 후, 이후 패치는 다른 작업환경에서 업로드했습니다 :)


https://android-review.googlesource.com/#/c/68220/