git-object-browser 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +13 -0
  4. data/Guardfile +11 -0
  5. data/LICENSE +22 -0
  6. data/README.md +18 -0
  7. data/Rakefile +2 -0
  8. data/bin/git-object-browser +5 -0
  9. data/git-object-browser.gemspec +18 -0
  10. data/htdocs/css/angular-ui.min.css +1 -0
  11. data/htdocs/css/bootstrap-responsive.css +1058 -0
  12. data/htdocs/css/bootstrap-responsive.min.css +9 -0
  13. data/htdocs/css/bootstrap.css +5389 -0
  14. data/htdocs/css/bootstrap.min.css +699 -0
  15. data/htdocs/css/font-awesome-ie7.css +645 -0
  16. data/htdocs/css/font-awesome.css +303 -0
  17. data/htdocs/css/main.css +22 -0
  18. data/htdocs/font/fontawesome-webfont.eot +0 -0
  19. data/htdocs/font/fontawesome-webfont.svg +255 -0
  20. data/htdocs/font/fontawesome-webfont.ttf +0 -0
  21. data/htdocs/font/fontawesome-webfont.woff +0 -0
  22. data/htdocs/img/glyphicons-halflings-white.png +0 -0
  23. data/htdocs/img/glyphicons-halflings.png +0 -0
  24. data/htdocs/index.html +114 -0
  25. data/htdocs/js/main.js +286 -0
  26. data/htdocs/js/vendor/angular-bootstrap-prettify.min.js +41 -0
  27. data/htdocs/js/vendor/angular-bootstrap.min.js +9 -0
  28. data/htdocs/js/vendor/angular-cookies.min.js +7 -0
  29. data/htdocs/js/vendor/angular-loader.min.js +7 -0
  30. data/htdocs/js/vendor/angular-resource.min.js +10 -0
  31. data/htdocs/js/vendor/angular-sanitize.min.js +13 -0
  32. data/htdocs/js/vendor/angular-ui-ieshiv.min.js +7 -0
  33. data/htdocs/js/vendor/angular-ui.min.js +7 -0
  34. data/htdocs/js/vendor/angular.js +14401 -0
  35. data/htdocs/js/vendor/angular.min.js +158 -0
  36. data/htdocs/js/vendor/bootstrap.js +2027 -0
  37. data/htdocs/js/vendor/bootstrap.min.js +6 -0
  38. data/htdocs/js/vendor/html5shiv.js +5 -0
  39. data/htdocs/js/vendor/jquery-1.8.2.min.js +2 -0
  40. data/htdocs/templates/directory.html +25 -0
  41. data/htdocs/templates/file.html +6 -0
  42. data/htdocs/templates/git.html +1 -0
  43. data/htdocs/templates/index.html +44 -0
  44. data/htdocs/templates/index_entry.html +54 -0
  45. data/htdocs/templates/info_refs.html +27 -0
  46. data/htdocs/templates/loading.html +1 -0
  47. data/htdocs/templates/notfound.html +7 -0
  48. data/htdocs/templates/object.html +54 -0
  49. data/htdocs/templates/objects.html +16 -0
  50. data/htdocs/templates/pack_file.html +15 -0
  51. data/htdocs/templates/pack_index.html +38 -0
  52. data/htdocs/templates/packed_object.html +111 -0
  53. data/htdocs/templates/packed_refs.html +27 -0
  54. data/htdocs/templates/ref.html +12 -0
  55. data/lib/git-object-browser.rb +37 -0
  56. data/lib/git-object-browser/dumper.rb +62 -0
  57. data/lib/git-object-browser/index_dumper.rb +77 -0
  58. data/lib/git-object-browser/main.rb +63 -0
  59. data/lib/git-object-browser/models/bindata.rb +68 -0
  60. data/lib/git-object-browser/models/directory.rb +61 -0
  61. data/lib/git-object-browser/models/git_object.rb +127 -0
  62. data/lib/git-object-browser/models/index.rb +77 -0
  63. data/lib/git-object-browser/models/index_entry.rb +95 -0
  64. data/lib/git-object-browser/models/index_reuc_extension.rb +31 -0
  65. data/lib/git-object-browser/models/index_tree_extension.rb +52 -0
  66. data/lib/git-object-browser/models/info_refs.rb +32 -0
  67. data/lib/git-object-browser/models/pack_file.rb +40 -0
  68. data/lib/git-object-browser/models/pack_index.rb +146 -0
  69. data/lib/git-object-browser/models/packed_object.rb +239 -0
  70. data/lib/git-object-browser/models/packed_refs.rb +39 -0
  71. data/lib/git-object-browser/models/plain_file.rb +24 -0
  72. data/lib/git-object-browser/models/ref.rb +32 -0
  73. data/lib/git-object-browser/object_dumper.rb +31 -0
  74. data/lib/git-object-browser/server/git_servlet.rb +209 -0
  75. data/lib/git-object-browser/server/main.rb +31 -0
  76. data/lib/git-object-browser/version.rb +3 -0
  77. data/spec/fixtures/generate_worktree.sh +103 -0
  78. data/spec/fixtures/git/indexes/001 +0 -0
  79. data/spec/fixtures/git/indexes/002-empty-tree-extension +0 -0
  80. data/spec/fixtures/git/plain_file +1 -0
  81. data/spec/fixtures/json/blob.json +9 -0
  82. data/spec/fixtures/json/merge-a.json +48 -0
  83. data/spec/fixtures/json/test3-tag.json +36 -0
  84. data/spec/fixtures/json/tree.json +20 -0
  85. data/spec/fixtures/worktree/_git/COMMIT_EDITMSG +1 -0
  86. data/spec/fixtures/worktree/_git/HEAD +1 -0
  87. data/spec/fixtures/worktree/_git/ORIG_HEAD +1 -0
  88. data/spec/fixtures/worktree/_git/config +11 -0
  89. data/spec/fixtures/worktree/_git/description +1 -0
  90. data/spec/fixtures/worktree/_git/hooks/applypatch-msg.sample +15 -0
  91. data/spec/fixtures/worktree/_git/hooks/commit-msg.sample +24 -0
  92. data/spec/fixtures/worktree/_git/hooks/post-update.sample +8 -0
  93. data/spec/fixtures/worktree/_git/hooks/pre-applypatch.sample +14 -0
  94. data/spec/fixtures/worktree/_git/hooks/pre-commit.sample +50 -0
  95. data/spec/fixtures/worktree/_git/hooks/pre-rebase.sample +169 -0
  96. data/spec/fixtures/worktree/_git/hooks/prepare-commit-msg.sample +36 -0
  97. data/spec/fixtures/worktree/_git/hooks/update.sample +128 -0
  98. data/spec/fixtures/worktree/_git/ignore +3 -0
  99. data/spec/fixtures/worktree/_git/index +0 -0
  100. data/spec/fixtures/worktree/_git/info/exclude +6 -0
  101. data/spec/fixtures/worktree/_git/info/refs +1 -0
  102. data/spec/fixtures/worktree/_git/logs/HEAD +10 -0
  103. data/spec/fixtures/worktree/_git/logs/refs/heads/branch-a +3 -0
  104. data/spec/fixtures/worktree/_git/logs/refs/heads/branch-b +2 -0
  105. data/spec/fixtures/worktree/_git/logs/refs/heads/master +4 -0
  106. data/spec/fixtures/worktree/_git/objects/00/cb8bfeb5b8ce906d39698e4e33b38341f5448f +1 -0
  107. data/spec/fixtures/worktree/_git/objects/07/31f9d4b6fa0475872be6a8ca263096f1d201cf +2 -0
  108. data/spec/fixtures/worktree/_git/objects/1d/3dc60b5a117054e43741d51e599ff31bb15f9f +0 -0
  109. data/spec/fixtures/worktree/_git/objects/26/4e42b1fef5bcb55acec162fdd5a068d79ae551 +0 -0
  110. data/spec/fixtures/worktree/_git/objects/28/3c06ddf1b31c14bb221d41173299e133b7753d +0 -0
  111. data/spec/fixtures/worktree/_git/objects/37/d1632d3f1159dad9cfb58e6c34312ab4355c49 +0 -0
  112. data/spec/fixtures/worktree/_git/objects/3a/2bf444f105c19b13ba5e75e884e10715e95a91 +0 -0
  113. data/spec/fixtures/worktree/_git/objects/40/a061aaf0cd0555449671a11993e4fed11f91a4 +2 -0
  114. data/spec/fixtures/worktree/_git/objects/53/2a1874c26cd19bd4d66e03218ab73e63de4357 +3 -0
  115. data/spec/fixtures/worktree/_git/objects/5b/719b165fde1964fb5a08adaf3b6e4f57ca1ff5 +0 -0
  116. data/spec/fixtures/worktree/_git/objects/61/cae34206bb889bae43ffdd22c17217485178bf +0 -0
  117. data/spec/fixtures/worktree/_git/objects/6c/444ac15f1e3c2a6869bd36ca7e58c39512106f +2 -0
  118. data/spec/fixtures/worktree/_git/objects/93/b714995d24c52180195876058a49c7d7fea0ad +0 -0
  119. data/spec/fixtures/worktree/_git/objects/96/25401ac3e19ef10868c140a76b719ac3f08fcf +0 -0
  120. data/spec/fixtures/worktree/_git/objects/b9/29ed2ab14f7489d5238a06d10d2f2c229a4ab4 +0 -0
  121. data/spec/fixtures/worktree/_git/objects/be/e0d26d33c284ee065e38bd7e81ae4bdc870f89 +4 -0
  122. data/spec/fixtures/worktree/_git/objects/c3/6491256978d26c08cd7aa97eee0f5631f96659 +0 -0
  123. data/spec/fixtures/worktree/_git/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 +0 -0
  124. data/spec/fixtures/worktree/_git/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b +0 -0
  125. data/spec/fixtures/worktree/_git/objects/e5/b6d4317cefa946d77fc91539f1f1e48b60836f +0 -0
  126. data/spec/fixtures/worktree/_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  127. data/spec/fixtures/worktree/_git/objects/info/packs +2 -0
  128. data/spec/fixtures/worktree/_git/objects/pack/pack-f1c1717e9264c12310c7bd3e7dcdd28924000ff6.idx +0 -0
  129. data/spec/fixtures/worktree/_git/objects/pack/pack-f1c1717e9264c12310c7bd3e7dcdd28924000ff6.pack +0 -0
  130. data/spec/fixtures/worktree/_git/packed-refs +2 -0
  131. data/spec/fixtures/worktree/_git/refs/heads/branch-a +1 -0
  132. data/spec/fixtures/worktree/_git/refs/heads/branch-b +1 -0
  133. data/spec/fixtures/worktree/_git/refs/heads/master +1 -0
  134. data/spec/fixtures/worktree/_git/refs/tags/simple-tag +1 -0
  135. data/spec/fixtures/worktree/_git/refs/tags/test3-tag +1 -0
  136. data/spec/fixtures/worktree/sample-a.txt +1 -0
  137. data/spec/fixtures/worktree/sample.txt +1 -0
  138. data/spec/fixtures/worktree/subdir/sample-sub.txt +0 -0
  139. data/spec/git-object-browser/main_spec.rb +31 -0
  140. data/spec/git-object-browser/models/bindata_spec.rb +144 -0
  141. data/spec/git-object-browser/models/git_object_spec.rb +49 -0
  142. data/spec/git-object-browser/models/index_spec.rb +42 -0
  143. data/spec/git-object-browser/models/index_tree_extension_spec.rb +58 -0
  144. data/spec/git-object-browser/models/plain_file_spec.rb +11 -0
  145. data/spec/spec_helper.rb +19 -0
  146. metadata +260 -0
@@ -0,0 +1,36 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to prepare the commit log message.
4
+ # Called by "git commit" with the name of the file that has the
5
+ # commit message, followed by the description of the commit
6
+ # message's source. The hook's purpose is to edit the commit
7
+ # message file. If the hook fails with a non-zero status,
8
+ # the commit is aborted.
9
+ #
10
+ # To enable this hook, rename this file to "prepare-commit-msg".
11
+
12
+ # This hook includes three examples. The first comments out the
13
+ # "Conflicts:" part of a merge commit.
14
+ #
15
+ # The second includes the output of "git diff --name-status -r"
16
+ # into the message, just before the "git status" output. It is
17
+ # commented because it doesn't cope with --amend or with squashed
18
+ # commits.
19
+ #
20
+ # The third example adds a Signed-off-by line to the message, that can
21
+ # still be edited. This is rarely a good idea.
22
+
23
+ case "$2,$3" in
24
+ merge,)
25
+ /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
26
+
27
+ # ,|template,)
28
+ # /usr/bin/perl -i.bak -pe '
29
+ # print "\n" . `git diff --cached --name-status -r`
30
+ # if /^#/ && $first++ == 0' "$1" ;;
31
+
32
+ *) ;;
33
+ esac
34
+
35
+ # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
36
+ # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
@@ -0,0 +1,128 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to blocks unannotated tags from entering.
4
+ # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
5
+ #
6
+ # To enable this hook, rename this file to "update".
7
+ #
8
+ # Config
9
+ # ------
10
+ # hooks.allowunannotated
11
+ # This boolean sets whether unannotated tags will be allowed into the
12
+ # repository. By default they won't be.
13
+ # hooks.allowdeletetag
14
+ # This boolean sets whether deleting tags will be allowed in the
15
+ # repository. By default they won't be.
16
+ # hooks.allowmodifytag
17
+ # This boolean sets whether a tag may be modified after creation. By default
18
+ # it won't be.
19
+ # hooks.allowdeletebranch
20
+ # This boolean sets whether deleting branches will be allowed in the
21
+ # repository. By default they won't be.
22
+ # hooks.denycreatebranch
23
+ # This boolean sets whether remotely creating branches will be denied
24
+ # in the repository. By default this is allowed.
25
+ #
26
+
27
+ # --- Command line
28
+ refname="$1"
29
+ oldrev="$2"
30
+ newrev="$3"
31
+
32
+ # --- Safety check
33
+ if [ -z "$GIT_DIR" ]; then
34
+ echo "Don't run this script from the command line." >&2
35
+ echo " (if you want, you could supply GIT_DIR then run" >&2
36
+ echo " $0 <ref> <oldrev> <newrev>)" >&2
37
+ exit 1
38
+ fi
39
+
40
+ if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
41
+ echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
42
+ exit 1
43
+ fi
44
+
45
+ # --- Config
46
+ allowunannotated=$(git config --bool hooks.allowunannotated)
47
+ allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
48
+ denycreatebranch=$(git config --bool hooks.denycreatebranch)
49
+ allowdeletetag=$(git config --bool hooks.allowdeletetag)
50
+ allowmodifytag=$(git config --bool hooks.allowmodifytag)
51
+
52
+ # check for no description
53
+ projectdesc=$(sed -e '1q' "$GIT_DIR/description")
54
+ case "$projectdesc" in
55
+ "Unnamed repository"* | "")
56
+ echo "*** Project description file hasn't been set" >&2
57
+ exit 1
58
+ ;;
59
+ esac
60
+
61
+ # --- Check types
62
+ # if $newrev is 0000...0000, it's a commit to delete a ref.
63
+ zero="0000000000000000000000000000000000000000"
64
+ if [ "$newrev" = "$zero" ]; then
65
+ newrev_type=delete
66
+ else
67
+ newrev_type=$(git cat-file -t $newrev)
68
+ fi
69
+
70
+ case "$refname","$newrev_type" in
71
+ refs/tags/*,commit)
72
+ # un-annotated tag
73
+ short_refname=${refname##refs/tags/}
74
+ if [ "$allowunannotated" != "true" ]; then
75
+ echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
76
+ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
77
+ exit 1
78
+ fi
79
+ ;;
80
+ refs/tags/*,delete)
81
+ # delete tag
82
+ if [ "$allowdeletetag" != "true" ]; then
83
+ echo "*** Deleting a tag is not allowed in this repository" >&2
84
+ exit 1
85
+ fi
86
+ ;;
87
+ refs/tags/*,tag)
88
+ # annotated tag
89
+ if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
90
+ then
91
+ echo "*** Tag '$refname' already exists." >&2
92
+ echo "*** Modifying a tag is not allowed in this repository." >&2
93
+ exit 1
94
+ fi
95
+ ;;
96
+ refs/heads/*,commit)
97
+ # branch
98
+ if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
99
+ echo "*** Creating a branch is not allowed in this repository" >&2
100
+ exit 1
101
+ fi
102
+ ;;
103
+ refs/heads/*,delete)
104
+ # delete branch
105
+ if [ "$allowdeletebranch" != "true" ]; then
106
+ echo "*** Deleting a branch is not allowed in this repository" >&2
107
+ exit 1
108
+ fi
109
+ ;;
110
+ refs/remotes/*,commit)
111
+ # tracking branch
112
+ ;;
113
+ refs/remotes/*,delete)
114
+ # delete tracking branch
115
+ if [ "$allowdeletebranch" != "true" ]; then
116
+ echo "*** Deleting a tracking branch is not allowed in this repository" >&2
117
+ exit 1
118
+ fi
119
+ ;;
120
+ *)
121
+ # Anything else (is there anything else?)
122
+ echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
123
+ exit 1
124
+ ;;
125
+ esac
126
+
127
+ # --- Finished
128
+ exit 0
@@ -0,0 +1,3 @@
1
+ *~
2
+ .DS_Store
3
+ _git
@@ -0,0 +1,6 @@
1
+ # git ls-files --others --exclude-from=.git/info/exclude
2
+ # Lines that start with '#' are comments.
3
+ # For a project mostly in C, the following would be a good set of
4
+ # exclude patterns (uncomment them if you want to use them):
5
+ # *.[oa]
6
+ # *~
@@ -0,0 +1 @@
1
+ 6698ccf4d63fdaf0388cb741b4e56aa754b530c2 refs/heads/master
@@ -0,0 +1,10 @@
1
+ 6698ccf4d63fdaf0388cb741b4e56aa754b530c2 532a1874c26cd19bd4d66e03218ab73e63de4357 git sample <git@example.com> 981172803 +0000 commit: commit 3
2
+ 532a1874c26cd19bd4d66e03218ab73e63de4357 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172804 +0000 commit: commit 4
3
+ 93b714995d24c52180195876058a49c7d7fea0ad 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172804 +0000 checkout: moving from master to branch-a
4
+ 93b714995d24c52180195876058a49c7d7fea0ad 6c444ac15f1e3c2a6869bd36ca7e58c39512106f git sample <git@example.com> 981172805 +0000 commit: commit 4a-1
5
+ 6c444ac15f1e3c2a6869bd36ca7e58c39512106f bee0d26d33c284ee065e38bd7e81ae4bdc870f89 git sample <git@example.com> 981172806 +0000 commit: commit 4a-2
6
+ bee0d26d33c284ee065e38bd7e81ae4bdc870f89 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172806 +0000 checkout: moving from branch-a to branch-b
7
+ 93b714995d24c52180195876058a49c7d7fea0ad 0731f9d4b6fa0475872be6a8ca263096f1d201cf git sample <git@example.com> 981172807 +0000 commit: commit 4b-1
8
+ 0731f9d4b6fa0475872be6a8ca263096f1d201cf 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172807 +0000 checkout: moving from branch-b to master
9
+ 93b714995d24c52180195876058a49c7d7fea0ad 37d1632d3f1159dad9cfb58e6c34312ab4355c49 git sample <git@example.com> 981172808 +0000 merge branch-a: Merge made by the 'recursive' strategy.
10
+ 37d1632d3f1159dad9cfb58e6c34312ab4355c49 40a061aaf0cd0555449671a11993e4fed11f91a4 git sample <git@example.com> 981172809 +0000 commit: add subdir
@@ -0,0 +1,3 @@
1
+ 0000000000000000000000000000000000000000 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172804 +0000 branch: Created from master
2
+ 93b714995d24c52180195876058a49c7d7fea0ad 6c444ac15f1e3c2a6869bd36ca7e58c39512106f git sample <git@example.com> 981172805 +0000 commit: commit 4a-1
3
+ 6c444ac15f1e3c2a6869bd36ca7e58c39512106f bee0d26d33c284ee065e38bd7e81ae4bdc870f89 git sample <git@example.com> 981172806 +0000 commit: commit 4a-2
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172804 +0000 branch: Created from master
2
+ 93b714995d24c52180195876058a49c7d7fea0ad 0731f9d4b6fa0475872be6a8ca263096f1d201cf git sample <git@example.com> 981172807 +0000 commit: commit 4b-1
@@ -0,0 +1,4 @@
1
+ 6698ccf4d63fdaf0388cb741b4e56aa754b530c2 532a1874c26cd19bd4d66e03218ab73e63de4357 git sample <git@example.com> 981172803 +0000 commit: commit 3
2
+ 532a1874c26cd19bd4d66e03218ab73e63de4357 93b714995d24c52180195876058a49c7d7fea0ad git sample <git@example.com> 981172804 +0000 commit: commit 4
3
+ 93b714995d24c52180195876058a49c7d7fea0ad 37d1632d3f1159dad9cfb58e6c34312ab4355c49 git sample <git@example.com> 981172808 +0000 merge branch-a: Merge made by the 'recursive' strategy.
4
+ 37d1632d3f1159dad9cfb58e6c34312ab4355c49 40a061aaf0cd0555449671a11993e4fed11f91a4 git sample <git@example.com> 981172809 +0000 commit: add subdir
@@ -0,0 +1 @@
1
+ x-�K�0 Y��#P�I*U���c�"�V�p{B�[�,�H��֞���,0������c*�8ǚ ��<��–��2䥵Y���.t�����Y`�m}1L���>��?7�7A�u�:�e���� .
@@ -0,0 +1,2 @@
1
+ x��M
2
+ B1�]���S;��2m�*X�xV���f�>��[�
@@ -0,0 +1,2 @@
1
+ x��K
2
+ 1D]��$���Wɧ��2��o`��Uymm�P�Fgr��1kF�2�����]�H�Wj�b����/�*�"Z*�P��vY�*&��͆D<�s��c{lۋ�:��?�p�k�D��$8�)1�<7�Ϛ���~��t� �B�
@@ -0,0 +1,3 @@
1
+ x��M
2
+ B1�]�����/�x�v:U���
3
+ �"^����G�K�q760�X�ZBF[�1X-b �� Q �QUk��1������Z�MS�\��b�����őf��k\�
@@ -0,0 +1,2 @@
1
+ x��Q
2
+ 1 D��)�/J�M�)�x��MU���<�E���53��Kk�i�WU�1�N��sL�4�Z�s��@�1p��!��;�)�}q��C�=��z�9�PU�#�~YV8�����M�0�I�߰�K;Bd#l=l��8��O����-�B0
@@ -0,0 +1,4 @@
1
+ x��]
2
+ 1 �}�)�.Jӟ����
3
+ �]�
4
+ �"^�y������[�a�WUO���TR���2%�T��Hk!��,��I�cE��2���I8i��KD����W��+\�ؓ�rW8 ��7�enG(1�l �vȌr���'�� �Ι.[BC
@@ -0,0 +1,2 @@
1
+ P pack-f1c1717e9264c12310c7bd3e7dcdd28924000ff6.pack
2
+
@@ -0,0 +1,2 @@
1
+ # pack-refs with: peeled
2
+ 6698ccf4d63fdaf0388cb741b4e56aa754b530c2 refs/heads/master
@@ -0,0 +1 @@
1
+ bee0d26d33c284ee065e38bd7e81ae4bdc870f89
@@ -0,0 +1 @@
1
+ 0731f9d4b6fa0475872be6a8ca263096f1d201cf
@@ -0,0 +1 @@
1
+ 40a061aaf0cd0555449671a11993e4fed11f91a4
@@ -0,0 +1 @@
1
+ 93b714995d24c52180195876058a49c7d7fea0ad
@@ -0,0 +1 @@
1
+ 00cb8bfeb5b8ce906d39698e4e33b38341f5448f
@@ -0,0 +1 @@
1
+ test4a-2
@@ -0,0 +1 @@
1
+ test4
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module GitObjectBrowser
4
+ describe Main do
5
+ subject { Main.new }
6
+
7
+ describe '#find_target' do
8
+ it 'return git directory under the current directory' do
9
+ dir = subject.find_target(File.join(FIXTURES_DIR, 'worktree'), '_git')
10
+ dir.should match %r{/spec/fixtures/worktree/_git\z}
11
+ end
12
+
13
+ it 'return git directory under the parent directory' do
14
+ dir = subject.find_target(File.join(FIXTURES_DIR, 'worktree/subdir'), '_git')
15
+ dir.should match %r{/spec/fixtures/worktree/_git\z}
16
+ end
17
+
18
+ it 'return current git directory' do
19
+ dir = subject.find_target(File.join(FIXTURES_DIR, 'worktree/_git'), '_git')
20
+ dir.should match %r{/spec/fixtures/worktree/_git\z}
21
+ end
22
+
23
+ it 'use current directory if no arguments' do
24
+ Dir.chdir(File.join(FIXTURES_DIR, 'worktree')) do
25
+ dir = subject.find_target(nil, '_git')
26
+ dir.should match %r{/spec/fixtures/worktree/_git\z}
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,144 @@
1
+ require 'spec_helper.rb'
2
+
3
+ module GitObjectBrowser::Models
4
+ describe Bindata do
5
+ let(:io) { StringIO.new('abcdefg') }
6
+ subject { Bindata.new(io) }
7
+
8
+ describe '#switch_source' do
9
+ it 'should change source temporary' do
10
+ io2 = StringIO.new('ABCDEFG')
11
+ subject.raw(2)
12
+ subject.switch_source(io2) do
13
+ subject.raw(3).should eq 'ABC'
14
+ end
15
+ subject.raw(3).should eq 'cde'
16
+ end
17
+ end
18
+
19
+ describe '#raw' do
20
+ it 'should return string' do
21
+ subject.raw(3).should eq 'abc'
22
+ end
23
+
24
+ it 'should return empty string and the position does not move when read 0 byte' do
25
+ subject.raw(0).should eq ''
26
+ subject.raw(1).should eq 'a'
27
+ subject.raw(0).should eq ''
28
+ subject.raw(2).should eq 'bc'
29
+ end
30
+
31
+ it 'should not raise error if the argument is greater than the real size' do
32
+ subject.raw(100).should eq 'abcdefg'
33
+ end
34
+
35
+ it 'should return nil if the position is at the end of stream' do
36
+ subject.bytes(100)
37
+ subject.raw(1).should eq nil
38
+ end
39
+ end
40
+
41
+ describe '#bytes' do
42
+ it 'should return byte code array' do
43
+ subject.bytes(3).should eq [97, 98, 99]
44
+ end
45
+
46
+ it 'should return empty array and the position does not move when read 0 byte' do
47
+ subject.bytes(0).should eq []
48
+ subject.bytes(1).should eq [97]
49
+ subject.bytes(0).should eq []
50
+ subject.bytes(2).should eq [98, 99]
51
+ end
52
+
53
+ it 'should not raise error if the argument is greater than the real size' do
54
+ subject.bytes(100).should eq (97..103).to_a
55
+ end
56
+
57
+ it 'should raise error if the position is at the end of stream' do
58
+ subject.bytes(100)
59
+ expect { subject.bytes(1) }.to raise_error
60
+ end
61
+ end
62
+
63
+ describe '#byte' do
64
+ it 'should return first byte' do
65
+ subject.byte.should eq 97
66
+ subject.byte.should eq 98
67
+ end
68
+
69
+ it 'should raise error if the position is at the end of stream' do
70
+ subject.bytes(100)
71
+ expect { subject.byte }.to raise_error
72
+ end
73
+ end
74
+
75
+ describe '#int' do
76
+ it 'should return int value' do
77
+ subject.int.should eq 1633837924
78
+ end
79
+
80
+ it 'should raise error if the position is at the end of stream' do
81
+ subject.bytes(100)
82
+ expect { subject.int }.to raise_error
83
+ end
84
+ end
85
+
86
+ describe '#hex' do
87
+ it 'should return int value' do
88
+ subject.hex(2).should eq '6162'
89
+ end
90
+
91
+ it 'should raise error if the position is at the end of stream' do
92
+ subject.bytes(100)
93
+ expect { subject.hex(1) }.to raise_error
94
+ end
95
+ end
96
+
97
+ describe '#binstr' do
98
+ it 'should return int value' do
99
+ subject.binstr(2).should eq '0110000101100010'
100
+ end
101
+
102
+ it 'should raise error if the position is at the end of stream' do
103
+ subject.bytes(100)
104
+ expect { subject.binstr(1) }.to raise_error
105
+ end
106
+ end
107
+
108
+ describe '#find_char' do
109
+ it 'should not include passed character' do
110
+ subject.find_char('d').should eq 'abc'
111
+ subject.raw(3).should eq 'efg'
112
+ end
113
+
114
+ it 'should not raise error if the character is not found' do
115
+ subject.find_char('z').should eq 'abcdefg'
116
+ end
117
+ end
118
+
119
+ describe '#skip' do
120
+ it 'should start seek from current position' do
121
+ subject.raw(2)
122
+ subject.skip(2)
123
+ subject.raw(3).should eq 'efg'
124
+ end
125
+ end
126
+
127
+ describe '#seek' do
128
+ it 'should seek from beginning' do
129
+ subject.raw(2)
130
+ subject.seek(2)
131
+ subject.raw(3).should eq 'cde'
132
+ end
133
+ end
134
+
135
+ describe '#peek' do
136
+ it 'should not move position' do
137
+ subject.raw(3)
138
+ subject.peek(3).should eq 'def'
139
+ subject.raw(3).should eq 'def'
140
+ end
141
+ end
142
+
143
+ end
144
+ end