blaggard 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +66 -0
  6. data/README.md +84 -0
  7. data/Rakefile +20 -0
  8. data/bin/blaggard +55 -0
  9. data/blaggard.gemspec +18 -0
  10. data/config.yml.example +9 -0
  11. data/install.txt +60 -0
  12. data/lib/blaggard.rb +33 -0
  13. data/lib/blaggard/advertisement.rb +92 -0
  14. data/lib/blaggard/auth.rb +37 -0
  15. data/lib/blaggard/bundle.rb +20 -0
  16. data/lib/blaggard/console.rb +3 -0
  17. data/lib/blaggard/git.rb +82 -0
  18. data/lib/blaggard/group_config.rb +123 -0
  19. data/lib/blaggard/group_finder.rb +28 -0
  20. data/lib/blaggard/server.rb +311 -0
  21. data/script/console +7 -0
  22. data/spec/advertisement_spec.rb +81 -0
  23. data/spec/fixtures/spec_repo.git/FETCH_HEAD +2 -0
  24. data/spec/fixtures/spec_repo.git/HEAD +1 -0
  25. data/spec/fixtures/spec_repo.git/HEAD_TRACKER +1 -0
  26. data/spec/fixtures/spec_repo.git/config +53 -0
  27. data/spec/fixtures/spec_repo.git/index +0 -0
  28. data/spec/fixtures/spec_repo.git/logs/HEAD +7 -0
  29. data/spec/fixtures/spec_repo.git/logs/refs/heads/br2 +2 -0
  30. data/spec/fixtures/spec_repo.git/logs/refs/heads/master +2 -0
  31. data/spec/fixtures/spec_repo.git/logs/refs/heads/not-good +1 -0
  32. data/spec/fixtures/spec_repo.git/logs/refs/remotes/origin/HEAD +1 -0
  33. data/spec/fixtures/spec_repo.git/logs/refs/remotes/test/master +2 -0
  34. data/spec/fixtures/spec_repo.git/objects/08/b041783f40edfe12bb406c9c9a8a040177c125 +0 -0
  35. data/spec/fixtures/spec_repo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
  36. data/spec/fixtures/spec_repo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
  37. data/spec/fixtures/spec_repo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
  38. data/spec/fixtures/spec_repo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd +0 -0
  39. data/spec/fixtures/spec_repo.git/objects/1b/8cbad43e867676df601306689fe7c3def5e689 +0 -0
  40. data/spec/fixtures/spec_repo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b +0 -0
  41. data/spec/fixtures/spec_repo.git/objects/25/8f0e2a959a364e40ed6603d5d44fbb24765b10 +0 -0
  42. data/spec/fixtures/spec_repo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d +0 -0
  43. data/spec/fixtures/spec_repo.git/objects/2d/59075e0681f540482d4f6223a68e0fef790bc7 +0 -0
  44. data/spec/fixtures/spec_repo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 +0 -0
  45. data/spec/fixtures/spec_repo.git/objects/36/97d64be941a53d4ae8f6a271e4e3fa56b022cc +0 -0
  46. data/spec/fixtures/spec_repo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
  47. data/spec/fixtures/spec_repo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +2 -0
  48. data/spec/fixtures/spec_repo.git/objects/4a/23e2e65ad4e31c4c9db7dc746650bfad082679 +0 -0
  49. data/spec/fixtures/spec_repo.git/objects/4b/22b35d44b5a4f589edf3dc89196399771796ea +0 -0
  50. data/spec/fixtures/spec_repo.git/objects/52/1d87c1ec3aef9824daf6d96cc0ae3710766d91 +0 -0
  51. data/spec/fixtures/spec_repo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +2 -0
  52. data/spec/fixtures/spec_repo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
  53. data/spec/fixtures/spec_repo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af +1 -0
  54. data/spec/fixtures/spec_repo.git/objects/7b/4384978d2493e851f9cca7858815fac9b10980 +0 -0
  55. data/spec/fixtures/spec_repo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
  56. data/spec/fixtures/spec_repo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
  57. data/spec/fixtures/spec_repo.git/objects/84/9a5e34a26815e821f865b8479f5815a47af0fe +2 -0
  58. data/spec/fixtures/spec_repo.git/objects/94/4c0f6e4dfa41595e6eb3ceecdb14f50fe18162 +1 -0
  59. data/spec/fixtures/spec_repo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 +0 -0
  60. data/spec/fixtures/spec_repo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2 +2 -0
  61. data/spec/fixtures/spec_repo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +3 -0
  62. data/spec/fixtures/spec_repo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +2 -0
  63. data/spec/fixtures/spec_repo.git/objects/a6/5fedf39aefe402d3bb6e24df4d4f5fe4547750 +3 -0
  64. data/spec/fixtures/spec_repo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
  65. data/spec/fixtures/spec_repo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
  66. data/spec/fixtures/spec_repo.git/objects/ae/90f12eea699729ed24555e40b9fd669da12a12 +0 -0
  67. data/spec/fixtures/spec_repo.git/objects/b2/5fa35b38051e4ae45d4222e795f9df2e43f1d1 +2 -0
  68. data/spec/fixtures/spec_repo.git/objects/b6/361fc6a97178d8fc8639fdeed71c775ab52593 +0 -0
  69. data/spec/fixtures/spec_repo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +3 -0
  70. data/spec/fixtures/spec_repo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +3 -0
  71. data/spec/fixtures/spec_repo.git/objects/d0/7b0f9a8c89f1d9e74dc4fce6421dec5ef8a659 +0 -0
  72. data/spec/fixtures/spec_repo.git/objects/d6/c93164c249c8000205dd4ec5cbca1b516d487f +0 -0
  73. data/spec/fixtures/spec_repo.git/objects/d7/1aab4f9b04b45ce09bcaa636a9be6231474759 +0 -0
  74. data/spec/fixtures/spec_repo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  75. data/spec/fixtures/spec_repo.git/objects/e7/b4ad382349ff96dd8199000580b9b1e2042eb0 +0 -0
  76. data/spec/fixtures/spec_repo.git/objects/f1/425cef211cc08caa31e7b545ffb232acb098c3 +0 -0
  77. data/spec/fixtures/spec_repo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
  78. data/spec/fixtures/spec_repo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
  79. data/spec/fixtures/spec_repo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
  80. data/spec/fixtures/spec_repo.git/objects/fd/4959ce7510db09d4d8217fa2d1780413e05a09 +0 -0
  81. data/spec/fixtures/spec_repo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx +0 -0
  82. data/spec/fixtures/spec_repo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.pack +0 -0
  83. data/spec/fixtures/spec_repo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
  84. data/spec/fixtures/spec_repo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
  85. data/spec/fixtures/spec_repo.git/objects/pack/pack-d85f5d483273108c9d8dd0e4728ccf0b2982423a.idx +0 -0
  86. data/spec/fixtures/spec_repo.git/objects/pack/pack-d85f5d483273108c9d8dd0e4728ccf0b2982423a.pack +0 -0
  87. data/spec/fixtures/spec_repo.git/packed-refs +3 -0
  88. data/spec/fixtures/spec_repo.git/refs/heads/br2 +1 -0
  89. data/spec/fixtures/spec_repo.git/refs/heads/cannot-fetch +1 -0
  90. data/spec/fixtures/spec_repo.git/refs/heads/chomped +1 -0
  91. data/spec/fixtures/spec_repo.git/refs/heads/haacked +1 -0
  92. data/spec/fixtures/spec_repo.git/refs/heads/master +1 -0
  93. data/spec/fixtures/spec_repo.git/refs/heads/not-good +1 -0
  94. data/spec/fixtures/spec_repo.git/refs/heads/packed-test +1 -0
  95. data/spec/fixtures/spec_repo.git/refs/heads/subtrees +1 -0
  96. data/spec/fixtures/spec_repo.git/refs/heads/test +1 -0
  97. data/spec/fixtures/spec_repo.git/refs/heads/track-local +1 -0
  98. data/spec/fixtures/spec_repo.git/refs/heads/trailing +1 -0
  99. data/spec/fixtures/spec_repo.git/refs/notes/fanout +1 -0
  100. data/spec/fixtures/spec_repo.git/refs/remotes/test/master +1 -0
  101. data/spec/fixtures/spec_repo.git/refs/tags/master-r1 +1 -0
  102. data/spec/fixtures/spec_repo.git/refs/tags/master-r2 +1 -0
  103. data/spec/fixtures/spec_repo.git/refs/tags/test-r1 +1 -0
  104. data/spec/fixtures/spec_repo.git/refs/tags/test-r2 +1 -0
  105. data/spec/git_spec.rb +23 -0
  106. data/spec/group_config_spec.rb +64 -0
  107. data/spec/spec_helper.rb +42 -0
  108. data/spec/support/test_env.rb +17 -0
  109. metadata +197 -0
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ # Run a Ruby REPL.
3
+
4
+ set -e
5
+
6
+ cd $(dirname "$0")/..
7
+ exec /usr/bin/env pry -Ilib -r blaggard -r blaggard/console
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blaggard::Advertisement do
4
+ subject{ Blaggard::Advertisement }
5
+ context 'read' do
6
+ before do
7
+ @advert = subject.new(TestEnv.repo_path, ["group1", "group2"], 'upload-pack')
8
+ @repo_branches = ["refs/heads/br2", "refs/heads/cannot-fetch",
9
+ "refs/heads/chomped", "refs/heads/haacked",
10
+ "refs/heads/master", "refs/heads/not-good",
11
+ "refs/heads/packed", "refs/heads/packed-test",
12
+ "refs/heads/subtrees", "refs/heads/test",
13
+ "refs/heads/track-local", "refs/heads/trailing"]
14
+ @subset = ["refs/heads/test", "refs/heads/chomped"]
15
+ end
16
+ it 'should get the original advertisement properly' do
17
+ raw = @advert.raw_refs
18
+ expect(raw.first.split("\0").length).to eq(2)
19
+ expect(raw.last).to eq("0000")
20
+ end
21
+
22
+ it 'should properly hash out ref names' do
23
+ hash = @advert.refs_hash
24
+ # We may add more tags and things to the repo, this makes sure the
25
+ # basic subset is there for the test to pass
26
+ expect(hash.keys & @repo_branches).to eq(@repo_branches)
27
+ end
28
+
29
+ it 'should get the accessible branches from the meta config when permission is *' do
30
+ meta = @advert.instance_variable_get :@meta
31
+ allow(meta).to receive(:branches).and_return(["refs/heads/*"])
32
+ expect(@advert.accessible_branches).to eq(@repo_branches)
33
+ end
34
+
35
+ it 'should get a subset of branches for accessible branches' do
36
+ meta = @advert.instance_variable_get :@meta
37
+ allow(meta).to receive(:branches).and_return(@subset)
38
+ expect(@advert.accessible_branches).to eq(@subset)
39
+ end
40
+
41
+ it 'should update_line_length properly' do
42
+ wrong_line = "0042a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2.0.1\n"
43
+ right_line = "00d1a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2.0.1\n"
44
+ expect(@advert.update_line_length(wrong_line)).to eq(right_line)
45
+ end
46
+
47
+ it 'should properly figure out if the user can access the current HEAD' do
48
+ meta = @advert.instance_variable_get :@meta
49
+ allow(meta).to receive(:can_access_branch?).with('group1', :read, "refs/heads/master").and_return(true)
50
+ allow(meta).to receive(:can_access_branch?).with('group2', :read, "refs/heads/master").and_return(false)
51
+ expect(@advert.can_access_head?).to eq(true)
52
+
53
+ allow(meta).to receive(:can_access_branch?).with('group1', :read, "refs/heads/master").and_return(false)
54
+ allow(meta).to receive(:can_access_branch?).with('group2', :read, "refs/heads/master").and_return(false)
55
+ expect(@advert.can_access_head?).to eq(false)
56
+ end
57
+
58
+ context 'stubbed git call' do
59
+ before do
60
+ git = @advert.instance_variable_get :@git
61
+ time_ordered_refs = ["refs/heads/subtrees", "refs/heads/master", "refs/heads/not-good", "refs/heads/test", "refs/heads/chomped", "refs/heads/trailing", "refs/heads/br2", "refs/heads/cannot-fetch", "refs/heads/track-local", "refs/heads/packed-test", "refs/heads/packed", "refs/heads/haacked"]
62
+ allow(git).to receive(:time_ordered_refs).and_return(time_ordered_refs)
63
+ allow(@advert).to receive(:accessible_branches).and_return(@subset)
64
+ end
65
+ it 'should update the HEAD line of the advertisement if user cannot access HEAD' do
66
+ expect(@advert.update_head).to include("00cfe90810b8df3e80c413d903f631643c716887138d HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/test")
67
+ end
68
+ it 'should output the correct full advertisement' do
69
+ allow(@advert).to receive(:can_access_head?).and_return(true)
70
+ git_version = `git --version`.split.last
71
+ advertisement = "00d1a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/#{git_version}
72
+ 003de90810b8df3e80c413d903f631643c716887138d refs/heads/test
73
+ 0040e90810b8df3e80c413d903f631643c716887138d refs/heads/chomped
74
+ 003fe90810b8df3e80c413d903f631643c716887138d refs/tags/test-r2
75
+ 003f6dcf9bf7541ee10456529833502442f385010c3d refs/tags/test-r1
76
+ 0000"
77
+ expect(@advert.advertise).to eq(advertisement)
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,2 @@
1
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750 branch 'master' of git://example.com/git/testrepo.git
2
+ 258f0e2a959a364e40ed6603d5d44fbb24765b10 not-for-merge branch 'haacked' of git://example.com/git/testrepo.git
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1 @@
1
+ ref: HEAD
@@ -0,0 +1,53 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = true
5
+ logallrefupdates = true
6
+ [remote "test"]
7
+ url = git://github.com/libgit2/libgit2
8
+ fetch = +refs/heads/*:refs/remotes/test/*
9
+ [remote "joshaber"]
10
+ url = git://github.com/libgit2/libgit2
11
+ [remote "empty-remote-url"]
12
+ url =
13
+ pushurl =
14
+ [remote "empty-remote-pushurl"]
15
+ pushurl =
16
+ [remote "no-remote-url"]
17
+ fetch =
18
+ [remote "test_with_pushurl"]
19
+ url = git://github.com/libgit2/fetchlibgit2
20
+ pushurl = git://github.com/libgit2/pushlibgit2
21
+ fetch = +refs/heads/*:refs/remotes/test_with_pushurl/*
22
+
23
+ [branch "master"]
24
+ remote = test
25
+ merge = refs/heads/master
26
+ [branch "track-local"]
27
+ remote = .
28
+ merge = refs/heads/master
29
+ [branch "cannot-fetch"]
30
+ remote = joshaber
31
+ merge = refs/heads/cannot-fetch
32
+ [branch "remoteless"]
33
+ remote =
34
+ merge = refs/heads/master
35
+ [branch "mergeless"]
36
+ remote = test
37
+ merge =
38
+ [branch "mergeandremoteless"]
39
+ remote =
40
+ merge =
41
+
42
+ #sample of access control configuration file
43
+ [access "refs/heads/*"]
44
+ RWCD=Administrators:ProjectOwners
45
+
46
+ [access "refs/heads/master"]
47
+ RWCD=Adminstrators:ProjectOwners
48
+ R=RegisteredUsers
49
+
50
+ [access "refs/heads/cannot-fetch"]
51
+ RW=Administrators:ProjectOwners
52
+ R=RegisteredUsers:GroupA
53
+
@@ -0,0 +1,7 @@
1
+ 0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub <bstraub@github.com> 1335806563 -0700 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git
2
+ be3563ae3f795b2b4353bcce3a527ad0a4f7f644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1335806603 -0900 commit:
3
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750 5b5b025afb0b4c913b4c338a42934a3863bf3644 Ben Straub <bstraub@github.com> 1335806604 -0900 checkout: moving from master to 5b5b025
4
+ 5b5b025afb0b4c913b4c338a42934a3863bf3644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1335806605 -0900 checkout: moving from 5b5b025 to master
5
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750 c47800c7266a2be04c571c04d5a6614691ea99bd Ben Straub <bstraub@github.com> 1335806608 -0900 checkout: moving from master to br2
6
+ c47800c7266a2be04c571c04d5a6614691ea99bd a4a7dce85cf63874e984719f4fdd239f5145052f Ben Straub <bstraub@github.com> 1335806617 -0900 commit: checking in
7
+ a4a7dce85cf63874e984719f4fdd239f5145052f a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1335806621 -0900 checkout: moving from br2 to master
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 c47800c7266a2be04c571c04d5a6614691ea99bd Ben Straub <bstraub@github.com> 1335806608 -0700 branch: Created from refs/remotes/origin/br2
2
+ a4a7dce85cf63874e984719f4fdd239f5145052f a4a7dce85cf63874e984719f4fdd239f5145052f Ben Straub <bstraub@github.com> 1335806617 -0700 commit: checking in
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub <bstraub@github.com> 1335806563 -0800 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git
2
+ be3563ae3f795b2b4353bcce3a527ad0a4f7f644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1335806603 -0800 commit: checking in
@@ -0,0 +1 @@
1
+ 0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1336761944 -0700 branch: Created from master
@@ -0,0 +1 @@
1
+ 0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub <bstraub@github.com> 1335806563 -0700 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub <bstraub@github.com> 1335806565 -0800 update by push
2
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub <bstraub@github.com> 1335806688 -0800 update by push
@@ -0,0 +1,2 @@
1
+ x��Q
2
+ �0D��)��6�ͦ "xO���-�Fb��Eo��0 �Ǥ�,ske�[�Pn8R,EpD?�g�}�^3� ��<��G�hYK���8ЖDA��)���;g�ݧ���j�p�4����-������r���;�s�GA4ۺ=���(�in7�I�K�FE
@@ -0,0 +1,2 @@
1
+ x��� 1E�Ni@��k2 "X�$�YW0Yc����Ås���z����MD��0��8!�����s� X��g�d�::@X0�P�w�"F/����R��Uz��m�ZZ�����V}|�/�o5����I�!�1z��:v��Uim}�/�>
2
+ �F-
@@ -0,0 +1 @@
1
+ x��Aj!��?0����09�o}�H�6�}��jUPP��Z&Y��� Aԛ��p��Fd��pz�[f�Y��P�qLJ.,Z�`�Ů�.�`�v� �q
@@ -0,0 +1,2 @@
1
+ x�M� F]s�����41�x�(�I�����Kݽ/_��P@������!8�)es
2
+ � �N&FGSƄ�h�{+�C����Zzv�F�7Z��-����k�x\�[P�8��G�K/��^� l��>.4
@@ -0,0 +1 @@
1
+ x+)JMU044b040031Qrut�ueX�l��mmA�m�̣�J}G�;U�T���������WRQ�`6���Kǥ�^/�-*|��W��3P�y��`%�E���\&g��|�0���{Ӎ1X
@@ -0,0 +1,2 @@
1
+ x��M
2
+ �0F]��d2����<A~&�`����V����m�����ҡ7U�$�J�L9yM!�Gu��H�&U���>;�������X��EȎ5R�� �A�E &n}Z��<E}�=O[��������Ӽ^�,�^�#�ɿ�]�P�`>�A�
@@ -0,0 +1,3 @@
1
+ x��[
2
+ �0E��*f��դ "�W0��-�F�t�݁��pS[�Y��x�^
3
+ D�b CLhut��}�8X*4Z��sY���U��A��
@@ -0,0 +1,2 @@
1
+ x��;j1D��md�����ǎ|M��3`��V{ >���Q����vL0I?�!�4�Z=�!�צ8�F���!r�sQ�y�9�]$D�&�l6A�>jFW�ҵ IKNi��Z�%�S���
2
+ �� ������U~̽��>'��� �w�
@@ -0,0 +1,3 @@
1
+ x��Q
2
+ !@��s�B�Q"��� �ٱ
3
+ �Hl�JSer!�ZPTe*�j�U��Eo^��2�(���XS�€ED��O<Y��j$2�s_�&} ��,}��[~p�7~<��:� �����Z���p�?�1_��C0
@@ -0,0 +1,2 @@
1
+ x�A
2
+ �0�a�9��I� ���p'�1�Ѷ�v\x{c���V�p�vW�g��ǎ0x�[ ]"g�#{rD�
@@ -0,0 +1,3 @@
1
+ x��Kj1D��)z�UB��-0��uV9����<#������+�W<J���&8�/s��e���ȕKJ����S
2
+ �Rv��{��Q��r��Y�QN$H\E����=6�X5���K Fr)�(�dC��Ά�����j�s�}���9�c-�w8�o�\�r��I���:
3
+ l}F�W$Ds�ǣ��ٚOW�e�]V8-Ý��"U
@@ -0,0 +1,3 @@
1
+ x��Q
2
+ �0D��)�ʦ�I<�'�lR+�Fj��Eo��0<x�h���a ���]ș��XUl�PF)�z�4y�,\r 'S��-mI4
3
+ �Xh��&��F�}n+\���Y�-p|鷜oU�z;-��a��lt{��?�I�,:�o�R��cHK
@@ -0,0 +1,3 @@
1
+ # pack-refs with: peeled
2
+ 41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9 refs/heads/packed
3
+ 5b5b025afb0b4c913b4c338a42934a3863bf3644 refs/heads/packed-test
@@ -0,0 +1 @@
1
+ a4a7dce85cf63874e984719f4fdd239f5145052f
@@ -0,0 +1 @@
1
+ a4a7dce85cf63874e984719f4fdd239f5145052f
@@ -0,0 +1 @@
1
+ e90810b8df3e80c413d903f631643c716887138d
@@ -0,0 +1 @@
1
+ 258f0e2a959a364e40ed6603d5d44fbb24765b10
@@ -0,0 +1 @@
1
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750
@@ -0,0 +1 @@
1
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750
@@ -0,0 +1 @@
1
+ 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
@@ -0,0 +1 @@
1
+ 763d71aadf09a7951596c9746c024e7eece7c7af
@@ -0,0 +1 @@
1
+ e90810b8df3e80c413d903f631643c716887138d
@@ -0,0 +1 @@
1
+ 9fd738e8f7967c078dceed8190330fc8648ee56a
@@ -0,0 +1 @@
1
+ e90810b8df3e80c413d903f631643c716887138d
@@ -0,0 +1 @@
1
+ d07b0f9a8c89f1d9e74dc4fce6421dec5ef8a659
@@ -0,0 +1 @@
1
+ be3563ae3f795b2b4353bcce3a527ad0a4f7f644
@@ -0,0 +1 @@
1
+ a65fedf39aefe402d3bb6e24df4d4f5fe4547750
@@ -0,0 +1 @@
1
+ 5b5b025afb0b4c913b4c338a42934a3863bf3644
@@ -0,0 +1 @@
1
+ 6dcf9bf7541ee10456529833502442f385010c3d
@@ -0,0 +1 @@
1
+ e90810b8df3e80c413d903f631643c716887138d
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blaggard::Git do
4
+ subject { Blaggard::Git }
5
+ before do
6
+ @git = subject.new(TestEnv.repo_path)
7
+ end
8
+ it 'should correctly order the refs by time' do
9
+ expected = ["refs/heads/subtrees", "refs/heads/master", "refs/heads/not-good",
10
+ "refs/heads/test", "refs/heads/chomped", "refs/heads/trailing",
11
+ "refs/heads/br2", "refs/heads/cannot-fetch", "refs/heads/track-local",
12
+ "refs/heads/packed-test", "refs/heads/packed", "refs/heads/haacked"]
13
+ expect(@git.time_ordered_refs).to eq(expected)
14
+ end
15
+
16
+ it 'should get only the tags for the selected branch' do
17
+ expect(@git.tags_on_branch('refs/heads/test')).to eq(%W(test-r2 test-r1))
18
+ end
19
+
20
+ it 'should validate the git-ness of a directory' do
21
+ expect(@git.valid_repo?).to eq(true)
22
+ end
23
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blaggard::GroupConfig do
4
+ subject { Blaggard::GroupConfig }
5
+ before do
6
+ @config = subject.new(TestEnv.repo_path)
7
+ end
8
+
9
+ it "should create the directory structure" do
10
+ meta_dir = File.join(TestEnv.repo_path, 'refs/meta')
11
+ expect(File.directory?(meta_dir)).to eq(true)
12
+ expect(@config.groups).to eq({})
13
+ end
14
+
15
+ # This tests the cascade of group, priv and branch being created properly
16
+ it "should add a branch to a group properly" do
17
+ group = "admin_group"
18
+ branch = "refs/heads/test"
19
+
20
+ expect(@config.add_branch(group, :write, branch)).to eq(true)
21
+ expect(@config.branches([group], :write)).to include(branch)
22
+ end
23
+
24
+ context 'delete' do
25
+ before do
26
+ @group = "admin_group"
27
+ @branch = "refs/heads/test"
28
+ @config.add_branch(@group, :write, @branch)
29
+ end
30
+ it 'should delete a branch properly' do
31
+
32
+ expect(@config.delete_branch(@group, :write, @branch)).to eq(true)
33
+ expect(@config.branches([@group], :write)).not_to include(@branch)
34
+ end
35
+
36
+ it 'should delete a group properly and validate group existence' do
37
+ expect(@config.delete_group(@group)).to eq(true)
38
+ begin
39
+ @config.branches([@group], :write)
40
+ rescue => e
41
+ expect(e.message).to include("Group #{@group} does not exist.")
42
+ end
43
+ end
44
+ end
45
+ it 'should error if branch does not exist' do
46
+ group = "admin_group"
47
+ branch = "refs/heads/not-a-branch"
48
+ begin
49
+ @config.add_branch(group, :write, branch)
50
+ rescue => e
51
+ expect(e.message).to include("Branch name #{branch} invalid.")
52
+ end
53
+ end
54
+
55
+ it 'should validate privilege type' do
56
+ group = "admin_group"
57
+ branch = "test"
58
+ begin
59
+ @config.add_branch(group, :invalid, branch)
60
+ rescue => e
61
+ expect(e.message).to eq("Privilege must be either :read or :write")
62
+ end
63
+ end
64
+ end