Thursday, July 16, 2009

Scott Chacon at Ruby Kaigi- Using git and github to develop one million times faster

First presentation of the day by Scott Chacon was given in English and translated into Japanese.

Pro Git book- now at progit.org

Advantages to a DVCS

In git:
Everything is fast
Every clone is a backup
Works offline

Linux kernel was the first project to use it

Immutable, almost never removes data

Stores snapshots, not patches
Sees a commit as a full file version

Commit object is the meta data of the commit
Has a pointer to the parent

Branches- pointers to a commit

Automatically detects merge base

Object model- Branch- commits, trees, blobs

git saves the individual time because no network is needed for:
Diff calculation
file history
merging
branching
committing
etc.

Git allows for frictionless context switching, so you can try out new ideas and develop non-linearly.

Branching can be used as a patch queue system similar to "Quilt" or mercruial's "mq"

useful rebase commands-
Rebase –onto
Rebase –i

Git saves a team time because of the variety of workflows possible:
Centralized model
Integration Manager model- Sort of like github, don’t need to wait for maintainer to apply changes
Dictator/lieutenant model
Non-linear team model

It also saves time because:
Parallel development in separate repositories is possible

There is no necessary single point of failure
(You can push to a temporary repo if something goes wrong with the main repo)

Github purpose:
Share code, submit and accept patches, find projects

75% of forked projects have work contributed back

18000 projects with at least one watcher
25% of those have been contributed to.

Make it easy to put code online

Gitsourcing- take some generic code used at your company and put it online
Grit- 13 contributers, 41 commits, 1047 LOC
Jekyll- Cont 28, 1475 LOC, Commits 79
Github services andjavascript:void(0) gems- also open source

Q & A:

Why did you create git hub?
Git hosting was a pain in the ass.

Sometimes git acts weird on windows. Suggestions?
Git extensions, Tortoisegit, EGit for Eclipse

Git on Cygwin a good solution?
Some people don’t like cygwin.

(Handed out some github stickers)

Submodules?
“I don’t use submodules” “There are a lot of problems” “I use git subtree merging” “40 lines of Rake”
progit.org describes subtree/submodules

When do you merge and when do you rebase?
Rebase- Topic branches, back to the main branch
Merge- Get changes from other people
Rebase- Git-svn, use all the time

Thursday, July 9, 2009

Password protect remote resource

This came up the other day, and I wasn't sure how to handle it. The solution is simple, but not obvious. I'm trying to put as much code as possible in my posts, but this one is really more of a conceptual issue. The code is way simple.

Problem:

You have a link that points to a remote location, and you need to dynamically set params, which depend on login info.

Non-solution:

If the user is not logged in, send the user to the login page and then back to the page with the link, after they've logged in. This works, but asks to much of the user. They have to click the same link twice.

Solution:

What you really want is a way to wrap the remote resource with an action of your own. That index should do two things: redirect to the remote resource, and have a before filter that authorizes the user.