ãã®ã¨ã³ããªã¯ ã¯ã¦ãªãããããã¼ã¢ããã³ãã«ã¬ã³ãã¼ã®21æ¥ç®ã®ã¨ã³ããªã§ãã
developer.hatenastaff.com
id:motemen ããä½ã®ãªãã¸ããªç®¡çãã¼ã«ã§ããã¨ããã® ghq
ãæè¿ãããã使ãå§ããã¨ãã大å¤ä¾¿å©ã ã£ãã®ã§ããããããããæå
ã®~/work/
ã~/hobby/
ã«ã¯ãã§ã«git clone
ãããªãã¸ããªãå±±ã»ã©è»¢ãã£ã¦ãã¾ããä»åããããghq管çä¸ã®ãã£ã¬ã¯ããªã«ãã£ã¨ç§»ãã¦ghqã©ã¤ããã¹ã¿ã¼ãããã話ããã¾ãã
ghq
ghq ãã®ãã®ã«ã¤ãã¦ã®èª¬æã¯ä½è
ã®id:motemenããã®ã¨ã³ããªã詳ããã®ã§ããã¡ãããåç
§ãã ããã
motemen.hatenablog.com
代表çãªä½¿ãæ¹ã¯âããããæãã§ãã¾ãã ãããã©ããããã¨ãããã£ã¦ããã ããã®ã§ã¯ãªããã¨æãã¾ãã
[asato@praline01 ~]$ ghq get [email protected]:astj/p5-Test-WWW-Stub.git clone ssh://[email protected]/astj/p5-Test-WWW-Stub.git -> /Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub git clone ssh://[email protected]/astj/p5-Test-WWW-Stub.git /Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub Cloning into '/Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub'... remote: Counting objects: 329, done. remote: Compressing objects: 100% (31/31), done. remote: Total 329 (delta 16), reused 0 (delta 0), pack-reused 283 Receiving objects: 100% (329/329), 55.39 KiB | 0 bytes/s, done. Resolving deltas: 100% (121/121), done. Checking connectivity... done. $ ghq list -p | grep p5 /Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub $ ghq look p5-Test-WWW-Stub cd /Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub [github.com/astj/p5-Test-WWW-Stub]$ pwd /Users/asato/.ghq/github.com/astj/p5-Test-WWW-Stub
ghqã使ãå§ãã¦ä½ãè¯ãã£ãã
ã¾ãããããããã®ã§ãããå人çã«æãã¦ãã主ãªã¡ãªããã¯
- "åãååã ãã©éããªãã¸ããª"ãè¤æ°æ±ãæã«ã©ã®ååã§cloneããããããæ©ã¾ãªãã¦è¯ããªã£ã
- ãªãã¸ããªãæ¢ãæã«ãå¾è¿°ã®bash aliasã§ä¸çºã§æ¢ããããã«ãªã£ã¦ãè¨æ¶åãä¸è¦ã«ãªã£ã
ãããã§ãããªãã ããã¾ãå¬ãããã«è¦ãã¾ãããããªãã¸ããªã®ãã£ã¬ã¯ããªã«ç§»åãããæ°ããgit clone
æã¯åºæ¬çã«ããããï¼ãã¨ããæ°æã¡ãªã®ã§ãããã«æ°´ãå·®ãããã«æ¸ãã®ã¯ããã ãã§çµæ§å¹¸ãã¨ããæ°æã¡ãããã¾ãã
å¾ã¯ãæå
ã«å
¥ã£ã¦ããpercol
ã¨çµã¿åããã¦aliasãå®ç¾©ãã¦ãªãã¸ããªåãã¤ã³ã¯ãªã¡ã³ã¿ã«ãµã¼ããã¦ãã®ãã£ã¬ã¯ããªã«ç§»åãã¨ããã®ãã¹ã ã¼ãºã«è¡ããããã«ãã¦ããã¾ãã
alias repo="ghq look \`ghq list | percol\`"
ghqã使ãå§ããåã«æ©ãã ãã¨
ã¨ã¾ã便å©ã«ghqã使ã£ã¦ããã®ã§ãããghqã®ä¾¿å©ãã説ã人ãã¡ãå¨ãã«ç¶ã
å¢ãã¤ã¤ããä¸åããã£ã¨ãããã£ã¦ããã®ã¯ãã¨ã³ããªã®åé ã«ãæ¸ããããã«éå¤ã«git clone
ãããã£ã¬ã¯ããªãã¡ã®æ«è·¯ã§ãããã³ã¼ãèªãããã ãã«cloneãããªãã¸ããªã¯ææªè¦æ¨ã¦ã¦å度ghq get
ããã°è¯ãã®ã§ãããå®éã«ã³ã¼ãæ¸ãã¦ããªãã¸ããªã§ã¯ãç§èµã®ãã©ã³ããgit stash
ããã£ããããã¼ã«ã«ãã«ãã®ææã§git管çãã¦ããªããã¡ã¤ã«ã転ãã£ã¦ãããâ¦â¦ã¨ããã®ãã¾ã¾ããã®ã§æ¨ã¦ãããã«ãããã¾ãããã¾ããæ°ãå¢ãã¦ããã¨ã©ãã大äºã«ä½¿ãã¹ãã§ã©ããéã«æ¨ã¦ã¦ãããªãã¸ããªãªã®ãèããã®ãåå«ã§ãã
ghq-migrator
ããã§ãæ¢åã®ãªãã¸ããªã®git remote
ãè¦ã¦ããæãã«ãã£ã¬ã¯ããªã移ãã¦ãããéãªã·ã§ã«ã¹ã¯ãªãããæ¸ãã¦ãããã§ã¬ã¼ãã¨å¼è¶ããã¦ãã¾ããã¨ã«ãã¾ããã
ghq-migratorãªã©ã¨ã«ãã³ã¤ããååã§githubã«ãã¢ãããã¼ããã¦ããã¾ããbashã®ã¹ã¯ãªããã1æã¨ã10åã»ã©ã§æ¸ããéãªREADMEãç½®ãã¦ããã ãã§ããèªåã®å¼è¶ãã«ä½¿ã£ãç¨åº¦ãªã®ã§ä¸èº«ã¯éã ãã³ã¡ã³ããåºåã®è±èªã¯ã¶ã£å£ãã¦ãã¾ãããæè¿ã®Macã®ç°å¢ã§ãªãåããã¨ã¯åãã®ã§ã¯ãªãããªã¨æãã¾ãã
github.com
ã·ã§ã«ã¹ã¯ãªããã§åã£ããªãã·ã§ã³ã®è§£æãããã®ãé¢åã ã£ãã®ã§ãææããã¦åä½ã«ã¾ã¤ããè¨å®ããã¹ã¦ç°å¢å¤æ°ã§æ¸ã¾ãã¦ããã¾ãã~/work/SuperCoolRepository/
ãghq管çä¸ã«å¼ã£è¶ãããå ´åã¯
$ GHQ_MIGRATOR_ACTUALLY_RUN=1 ghq-migrator.bash ~/work/SuperCoolRepository
ã¨å®è¡ããã¨ãã·ã§ã«ã¹ã¯ãªãããgit remote
ãé å¼µã£ã¦èªãã§ããæãã«mv
ãã¦ããã¾ãã
é ã®GHQ_MIGRATOR_ACTUALLY_RUN=1
ããªãã¨dry-runã«ãªãã®ã§ããããªãå®è¡ããåã«ä¸åº¦dry-runããã¨ããå®å
¨ã§ãã
ã¾ããããã©ã«ãã ã¨git remote
ãè¤æ°è¨å®ããã¦ããå ´åã¯å¼è¶ããè¡ããªãã®ã§ãããããã¾ãç°å¢å¤æ°ã§GHQ_MIGRATOR_PREFER_ORIGIN=1
ãæå®ãã¦ããã¨originã®urlã«åããããã£ã¬ã¯ããªã«åæã«ç§»åãã¦ããã¾ãã(originã«è¤æ°urlãè¨å®ããã¦ããå ´åã®ãã³ããªã³ã°ã¯è«¦ãã¦ãã¾ãã諦ãã¦æã§åããã¦ãã ããâ¦)
urlãåãè²¼ãããã®ã«ä¸é¨ã¯sed
ã使ãã¾ããããç°¡åãªæååã®å å·¥ã«ã¯bashã®å¤æ°ã®ç¹æ®å±éã使ã£ã¦ãã¾ããä»ååãã¦ç¥ã£ããã©ä¾¿å©ããã ããªãã¡ã¬ã³ã¹æ¯åèªã¾ãªãã¨ããããã¨ããææ³ã§ããã以ä¸ã®ã¨ã³ããªã«ãä¸è©±ã«ãªãã¾ããã
ghq-migratorã使ã£ãå¼è¶ã
ãããã®æå
ã§ã¯ã以ä¸ã®ããã«éã«~/work/
以ä¸ãå
¨é¨migratorã«ãããæ®ã£ããªãã¸ããªã¯å¿
è¦ã«å¿ãã¦GHQ_MIGRATOR_PREFER_ORIGIN=1
ãæå®ãã¦èµ°ããç´ããã諦ãã¦æã§åãããªã©ãã¾ããã
$ export GHQ_MIGRATOR_ACTUALLY_RUN=1 $ cd ~/work; ls | xargs -I{} ~/hobby/ghq-migrator/ghq-migrator.bash {} $ ls -l (æ®ã£ããã£ã¬ã¯ããªãçºãã) $ GHQ_MIGRATOR_PREFER_ORIGIN=1 ~/hobby/ghq-migrator/ghq-migrator.bash ./(originã®urlã«ç§»ãã¦åé¡ç¡ããããªãªãã¸ããª)/
移åããããªãã£ãä¸é¨ã¯æã§åãããªã©ãã¾ããããæå
ã«è»¢ããã¦ãããªãã¸ããªã®å¤§åãghq管çä¸ã«ç§»è¡ã§ãããããå®å¿ãã¦ä»æ¥ãrepo
ã¨ä¸çºæã£ã¦ä½æ¥ãã£ã¬ã¯ããªã¸ã¨ç§»åãã¦ãã¾ãã
ã¾ã¨ã
ã¨ãããã¨ã§ãèªåã§æ¸ããã·ã§ã«ã¹ã¯ãªããã«ãã£ã¦æå
ã®ãªãã¸ããªãghq管çä¸ã«ç§»è¡ããããã¨ã«æåãã¾ããããªãã¸ããªã®ç§»è¡ãé¢åã§ghq
ãèºèºã£ã¦ããæ¹ã¯ãããæ©ä¼ã«å¼ã£è¶ããã¦ã¿ã¦ãããã®ã§ã¯ãªãã§ããããã
ghq-migrator ã®åä½ã«é¢ãã¦ä½è (ãã¤çè )ã¯ä¸åã®è²¬ä»»ãåãã¾ããããæå ã§åä½ã確èªã®ä¸ã§ãå©ç¨ãã ããã
ææ¥ã®æ å½ã¯id:sharataniããã§ãã