Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

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

hakobe (Yohei Fushii)

January 23, 2013
Tweet

More Decks by hakobe (Yohei Fushii)

Other Decks in Technology

Transcript

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

    ‣Perl/JavaScript/Objective-C/Java ‣Hatena-Bookmark ‣GitHub Enterprise maintenance Self Introduction 
  2. 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. 
  3. Workflow around Git •Repository viewers (in-house) • Neo Ashika •

    Hatena::CodeFridge ‣Git repos. browser ‣Task management system •Blog-based Groupware • Hatena::Group 
  4. 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
  5. 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. 
  6. Before GHE 16 developer developer developer git push git push

    git push Hatena Repos Server App server deploy 3FQPT" 3FQPT#
  7. After GHE  developer developer developer git push git push

    git push GHE Mirroring App server deploy Hatena Repos Server 3FQPT" 3FQPT# 3FQPT"
  8. 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
  9. 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 
  10. 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 [email protected] Register the mirroring pair to ghm (next). [email protected] .JSSPS
  11. ghm •in-house Web Application for mirroring pairs management • Stores

    mirroring pairs • Has WebHook API that invoke mirroring (later) • Provides some APIs 
  12. 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 = [email protected]:/hatena/Hatena-Bookmark DPOpH!NJSSPSETU )BUFOB`TSFQPT
  13. • “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.
  14. • “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
  15. Mirroring behavior  developer git push Hatena Repos GHE ghm

    Web Hook call git remote update replace all refs by git remote update
  16. git-hatena •repository setting tools • git hatena mirror ‣Set up

    mirroring • git hatena sync ‣Change current repository setting • Easy install (1file & few dependencies) 
  17. 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
  18. 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
  19. 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 
  20. 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 
  21. 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... 
  22. 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