Files: f791da7ccc8e720c47c297e2a39c746bfba7b8c3 / test / repo.js
1189 bytesRaw
1 | function hexToStr(str) { |
2 | var buf = new Buffer(str.length / 2) |
3 | buf.hexWrite(str) |
4 | return buf.toString('ascii') |
5 | } |
6 | |
7 | var date = '1000000000 -0500' |
8 | |
9 | var user = { |
10 | name: 'test', |
11 | email: 'test@localhost' |
12 | } |
13 | user.str = user.name + ' <' + user.email + '>' |
14 | |
15 | var file = { |
16 | data: new Buffer('i am a file'), |
17 | hash: '68bd10497ea68e91fa85024d0a0b2fe54e212914' |
18 | } |
19 | var fileName = 'blah.txt' |
20 | |
21 | var tree = { |
22 | hash: '75c54aa020772a916853987a03bff7079463a861', |
23 | data: new Buffer([0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x62, 0x6c, 0x61, 0x68, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x68, 0xbd, 0x10, 0x49, 0x7e, 0xa6, 0x8e, 0x91, 0xfa, 0x85, 0x02, 0x4d, 0x0a, 0x0b, 0x2f, 0xe5, 0x4e, 0x21, 0x29, 0x14]) |
24 | // data: '100644 ' + fileName + '\0' + hexToStr(file.hash) |
25 | } |
26 | |
27 | var commitMessage = 'Initial commit' |
28 | var commit = { |
29 | hash: 'edb5b50e8019797925820007d318870f8c346726', |
30 | data: new Buffer(['tree ' + tree.hash, |
31 | 'author ' + user.str + ' ' + date, |
32 | 'committer ' + user.str + ' ' + date, |
33 | '', commitMessage, '' |
34 | ].join('\n')) |
35 | } |
36 | |
37 | exports.date = date |
38 | exports.user = user |
39 | exports.file = file |
40 | exports.fileName = fileName |
41 | exports.tree = tree |
42 | exports.commitMessage = commitMessage |
43 | exports.commit = commit |
44 |
Built with git-ssb-web