なめらかにGHEに移行する方法

 なめらかにGHEに移行する方法

GHEのリポジトリと既存のリポジトリをうまく共存する方法について解説します

7e8bb5931a14030dc6a297aa364197bf?s=128

hakobe (Yohei Fushii)

January 23, 2013
Tweet

Transcript

  1. 2.

    • @hakobe / id:hakobe932 • Yohei Fushii • Web Engineer

    ‣Perl/JavaScript/Objective-C/Java ‣Hatena-Bookmark ‣GitHub Enterprise maintenance Self Introduction 
  2. 3.
  3. 6.

    Git @ Hatena Inc. •Switched from SVN around 2008/05 •Over

    700 repositories • projects/submodules/server configs/ experiments etc... •Self hosting • Every alive developing projects uses Git. 
  4. 7.

    Workflow around Git •Repository viewers (in-house) • Neo Ashika •

    Hatena::CodeFridge ‣Git repos. browser ‣Task management system •Blog-based Groupware • Hatena::Group 
  5. 8.
  6. 9.
  7. 13.

    Problems •We cannot move all projects to GHE • We

    have over 700 repositories • To choose projects to move is difficult and boring... •Some teams do not want GHE  We need a way to Switch to GHE Gradually
  8. 14.

    Goals •Both GHE and existing repos can be used for

    production. •Anyone can start using GHE easily. •GHE failure should not cause to stop deployment. 
  9. 16.

    Before GHE 16 developer developer developer git push git push

    git push Hatena Repos Server App server deploy 3FQPT" 3FQPT#
  10. 17.

    After GHE  developer developer developer git push git push

    git push GHE Mirroring App server deploy Hatena Repos Server 3FQPT" 3FQPT# 3FQPT"
  11. 18.

    Mirroring  developer git push Hatena Repos GHE ghm (later)

    Web Hook call git remote update replace all refs by git remote update Mirrors changes on GHE to Hatena’s Repos
  12. 19.

    Setting up Mirroring 1.Register Hatena repos and GHE repos as

    a Mirroring Pair 2.Set mirroring config to Hatena repos 3.Set push-denial hook to Hatena repos 4.Register WebHook for mirroring to GHE repos 
  13. 20.

    1. Register Hatena repos and GHE repos as a Mirroring

    Pair •Mirroring Pair  hatena.repos:/path/to/projects/Hatena-Bookmark.git ghe.repos/hatena/Hatena-Bookmark.git dst@hatena.repos Register the mirroring pair to ghm (next). src@ghe.repos .JSSPS
  14. 21.

    ghm •in-house Web Application for mirroring pairs management • Stores

    mirroring pairs • Has WebHook API that invoke mirroring (later) • Provides some APIs 
  15. 22.
  16. 23.

    2. Set mirroring config to Hatena repos • refs/ on

    the remote will be directly mirrored into refs/ → “git remote update“ replaces everything under refs/ by GHE repos’s refs/ • This is the same as “git clone --mirror”  [remote "origin"] fetch = +refs/*:refs/* mirror = true url = git@ghe.repos:/hatena/Hatena-Bookmark DPOpH!NJSSPSETU )BUFOB`TSFQPT
  17. 24.

    • “git remote update” destroy changes in dst repos(Hatena repos)

    • Confirm the repos has mirroring config at pre- receive hook by ghm API 3. Set push-denial hook to Hatena repos  http://ghm/api/repos?mirror=projects/Hatena-Bookmark HINSFQPT"1* Returns repos info if the repos pair is registered.
  18. 25.

    • “git remote update” replaces dst(Hatena repos) contents by latest

    src(GHE repos) contents 4.Register WebHook for mirroring to GHE repos  ssh hatena.repos.host \ 'env GIT_DIR="/path/to/HatenaBookmark.git" git remote update' HIN8FC)PPL"1*SVOT
  19. 26.

    Mirroring behavior  developer git push Hatena Repos GHE ghm

    Web Hook call git remote update replace all refs by git remote update
  20. 28.

    git-hatena •repository setting tools • git hatena mirror ‣Set up

    mirroring • git hatena sync ‣Change current repository setting • Easy install (1file & few dependencies) 
  21. 29.

    git hatena mirror • Automatic settings for mirroring and project

    generation  $ git hatena mirror \ hatena/Hatena-Bookmark projects/Hatena-Bookmark hatena.repos:/path/to/projects/Hatena-Bookmark.git ghe.repos/hatena/Hatena-Bookmark.git .JSSPS
  22. 30.

    git hatena sync • Reflect the mirroring setting to local

    repository setting ‣ghm API can returns corresponding repos of mirroring pairs  $ cd /path/to/local/repos $ git hatena sync
  23. 31.

    Goals & Solutions •Both GHE and existing repos can be

    used for production. → mirroring •Anyone can start using GHE easily → git-hatena •GHE failure should not cause to stop deployment. → mirroring, rich server 
  24. 32.

    GHE and Hatena •from 2012/8 •80% teams are using GHE

    •25% active repositories are on GHE • many submodules are’t on GHE • Gradually increasing 
  25. 33.

    Dev flow workshop (in-house) •We are GHE newbies •Sharing the

    workflow of development • from spec definition to production release • Issues, Pull Request, Code Review, Test, CI, deploy, etc... 
  26. 34.

    Conclusion •git and Hatena • We are heavy git users

    • 700 over repositories •Environment for Gradual Switches • Mirroring (ghm) • Automation tool (git-hatena) • High-spec server •GHE and Hatena