Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

YAPC::Asia 2014: Writing tools with Git

motemen
August 29, 2014

YAPC::Asia 2014: Writing tools with Git

motemen

August 29, 2014
Tweet

More Decks by motemen

Other Decks in Technology

Transcript

  1. ghq • Go • ͍͍ײ͡ʹ git clone / hg clone

    • ghq get <URL> • ghq look <repo> ghqΛ࢖ͬͨϩʔΧϧϦϙδτϦͷ౷Ұతɾޮ཰తͳ؅ཧʹ͍ͭͯ ghq + peco/percol 5
  2. git-unify • sh • ෳ਺ͷϩʔΧϧΫϩʔϯͷ .git ҎԼ Λڞ༗ git-hsm: git

    submodule ͰαϒϞδϡʔϧ؅ཧͯ͠ΔͱσΟ εΫ༰ྔΛѹഭͯ͠ٽ͖ͨ͘ͳΓ·ͤΜ͔ 9
  3. Ҿ਺ͷղऍ • git browse-remote [<rev>] • git browse-remote feature/cool •

    git browse-remote b08d29 • git browse-remote v0.2-pre1~1 • git browse-remote @{3} 16
  4. <rev> ͋Ε͜Ε • SHA1: 3b3ab428ec05924e9a96d16a05959150485f51a0, … • refname: “A symbolic

    ref name”, master, v2.0, HEAD… • λά/ϒϥϯν/ϦϞʔτ • “master” → “refs/heads/master” • “v2.0” → “refs/tags/v2.0” • “origin” → “refs/remotes/origin/HEAD” • ࣮ଶ͸ .git/ ҎԼ 18
  5. <rev> ͋Ε͜Ε • <rev>^{n} • <rev>~{n} • [<refname>]@{yesterday}, @{3} •

    describeOutput: v0.5-3-g0829bd • :/<text> • …and more! git-rev-parse: SPECIFYING REVISIONS 19
  6. gbr: Ҿ਺ͳ͠ • ҉໧ͷ HEAD • ϒϥϯν or λά or

    ίϛοτ • git symbolic-ref -q HEAD 23
  7. gbr: Ҿ਺͋Γ • git name-rev —name-only • rev ʹγϯϘϦοΫͳ໊લΛ༩͑Δ •

    “5d7d3957” → “remotes/origin/master” • “HEAD~3” → “tags/v0.4-pre" • git rev-parse —symbolic-full-name • refname Λ׬શ໊ʹ • “v0.4” → “refs/tags/v0.4” 25
  8. OPTIONS_SPEC OPTS_SPEC="\! some-command [options] <args>...! ! some-command does foo and

    bar!! --! h,help show the help! ! foo some nifty option --foo! bar= some cool option --bar with an argument! baz=arg another cool option --baz with a named argument! qux?path qux may take a path argument but has meaning by itself! ! An option group Header! C? option C with an optional argument"! 30 git-rev-parse: PARSEOPT
  9. OPTIONS_SPEC OPTS_SPEC="\! some-command [options] <args>...! ! some-command does foo and

    bar!! --! h,help show the help! ! foo some nifty option --foo! bar= some cool option --bar with an argument! baz=arg another cool option --baz with a named argument! qux?path qux may take a path argument but has meaning by itself! ! An option group Header! C? option C with an optional argument"! 31 git-rev-parse: PARSEOPT
  10. git rev-parse • git rev-parse --show-toplevel • τοϓσΟϨΫτϦͷઈରύε • git

    rev-parse --git-dir • git rev-parse --show-prefix • cwd ͔Βͷ૬ରύε 33
  11. Get ϦϞʔτ • $branch = `git symbolic-ref -q HEAD` •

    $remote = `git config branch.$branch.remote` • $url = `git config remote.$remote.url` 37
  12. git config --get-urlmatch • URL ͝ͱʹઃఆΛมߋͰ͖Δ • git config --get-urlmatch


    ghq.vcs https://example.com/git/ # => “git” 45 [ghq]! vcs = unknown! [ghq "https://example.com/git/"]! vcs = git! [ghq "https://example.com/hg/"]! vcs = hg
  13. ͓ΘΓ • ศརͳ Git αϒίϚϯυୡ • symbolic-ref / name-rev /

    rev-parse / git-sh-setup / config / remote • …and more • ׆༻͠·͠ΐ͏ • --help -w 47