hadley/devtools — pull request #274 by wch (2013-04-01 18:43:15+00:00)
Title: Add SHA1 check to source_url

Here's what it does when you supply no hash, the correct hash, and the incorrect hash:

```
# No hash: prints out SHA1 hash and runs code
source_url("https://raw.github.com/gist/1654919/8161f74fb0ec26d1ba9fd54473a96f768ed76f56/test2.r")
# SHA-1 hash of file is 3bc091265c4a543bf772ca99de84db07d53a2468
# [1] 2

# With correct hash: just runs code
source_url("https://raw.github.com/gist/1654919/8161f74fb0ec26d1ba9fd54473a96f768ed76f56/test2.r",
sha1="3bc091265c4a543bf772ca99de84db07d53a2468")
# [1] 2

# With the wrong hash: throws error and doesn't run
source_url("https://raw.github.com/gist/1654919/8161f74fb0ec26d1ba9fd54473a96f768ed76f56/test2.r",
sha1="3bc091265c4a543bf772ca99de84db07d53a0000")
# Error in source_url("https://raw.github.com/gist/1654919/8161f74fb0ec26d1ba9fd54473a96f768ed76f56/test2.r", :
# SHA-1 hash of downloaded file (3bc091265c4a543bf772ca99de84db07d53a2468)
# does not match expected value (3bc091265c4a543bf772ca99de84db07d53a0000)
```