More Related Content
Similar to Git pyfes201207-presen
Similar to Git pyfes201207-presen (20)
More from Kouhei Maeda (9)
Git pyfes201207-presen
- 2. 自己紹介
まえだこうへい
▶ Debian JP Project Leader(2011, 2012) / CouchDB JP
▶ 勤務先:渋谷の会社
▶ Python 関連の Debian パッケージのメンテナンスなど
▶ 職場で使用している OpenStack の構築・運用で必要な、
周辺ツールの開発、構築とか
▶ 執筆
▶ Git によるバージョン管理 (オーム社)
▶ KVM 徹底入門 (翔泳社)
▶ ゆったリラックス! CouchDB があるところ (@IT) #5
▶ 知って見るみる KVM(@IT)
. . . . . .
- 3. 宣伝
Git によるバージョン管理 http://ssl.ohmsha.co.jp/
cgi-bin/menu.cgi?ISBN=978-4-274-06864-5
. . . . . .
- 6. 私の pyfes に対するイメージ (偏見)
▶ 参加者の公用語は Python
▶ シェルや、シェルスクリプトを使っていたら、怒られる
▶ Git なにそれ?Mercurial だろ jk
▶ LaTeX なにそれ?Sphi(ry
怖いところに、のこのこ来てもうた…。
. . . . . .
- 8. Python で Git を扱う方法
▶ Git のコマンドを使う
▶ blueprint のように subprocess.Popen を使う方法1
▶ gittools のように commands.getstatusoutput() を使う方
法2
▶ Python 製の Git ツールを使う
▶ legit 3
▶ GitPython 4
▶ Dulwich 5
▶ などなど。
1
https://github.com/devstructure/blueprint
2
https://github.com/farktronix/gittools
3
https://github.com/kennethreitz/legit
4
https://github.com/gitpython-developers/GitPython
5
http://www.samba.org/~jelmer/dulwich/ .
. . . . .
- 9. 今回は GitPython にしてみました。
選んだ理由は、
$ apt-cache search git python
で、
▶ 最初に目にとまったのが GitPython だった
▶API のドキュメントも充実していた
とただそれだけです。
. . . . . .
- 10. インストール
$ sudo apt-get install python-git
ちなみに、
▶ Debian の Python パッケージングポリシーは、パッケー
ジ名が’python-’ となります
▶ blockdiag シリーズも、’python-blockdiag’ のようになり
ます
. . . . . .
- 12. git init
ローカルリポジトリ
import git
git_repo = git.Git(’/tmp/practice’)
git_repo.init()
ベアリポジトリ
git_repo_bare = git.Git(’/tmp/practice-bare’)
git_repo_bare.init(bare=True)
. . . . . .
- 13. git add
git_cmd = git.cmd.Git(’/tmp/practice’)
f = open(’/tmp/practice/hoge’, ’w’)
f.write(’hoge’)
f.close()
git_cmd.add(’hoge’)
. . . . . .
- 14. git commit
g_cmd.commit(m=’Add hoge’)
. . . . . .
- 19. git rm
git_cmd.rm(’hoge’)
. . . . . .
- 21. 困るのは使い道。
▶ 私は bash の代わりに python の interactive モードや
ipython で生活しているわけではない、一般人
▶ Git コマンドではなく、Python で Git を使うと言って
も、アイデアがありません
▶ ありきたりなのは、Wiki とか Web アプリで Git リポジ
トリを読み込むとか、それ何て GitLab とか Gitorious
. . . . . .
- 24. どの辺が GitPython?
▶ LXC ホストおよびコンテナを管理するためのリポジト
リ ($HOME/.iori)
▶ LXC ホストを登録すると、ブランチを一つ作成
▶ コンテナを作成すると、XML ファイルを保存して、git
add/commit
▶ コンテナを削除すると、git rm/commit
と先ほど説明したことをやっているだけですね。
https://github.com/mkouhei/iori/blob/master/src/
iori/repo.py
. . . . . .
- 27. 最近の CouchDB
▶ (かなり前に)CouchDB 1.2.0 がリリース
▶ (Wheezy フリーズ直前に) Debian の CouchDB が 1.2.0
にアップデート
▶ (先週くらい?)Cloudant がロンドンオリンピックのシス
テムで採用されたというニュースリリース
▶ (一昨日)Couchbase T シャツが余ってしょうがないから
どうしよう?という@yssk22 からの相談
. . . . . .