dandelion 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/README.md +11 -8
  2. data/Rakefile +8 -1
  3. data/dandelion.gemspec +2 -2
  4. data/lib/dandelion/cli.rb +119 -74
  5. data/lib/dandelion/deployment.rb +5 -2
  6. data/lib/dandelion/service.rb +91 -15
  7. data/lib/dandelion/version.rb +1 -1
  8. data/test/fixtures/diff +3 -0
  9. data/test/fixtures/ls_tree +4 -0
  10. data/test/test_diff_deployment.rb +123 -0
  11. data/test/test_git.git/HEAD +1 -0
  12. data/test/test_git.git/config +5 -0
  13. data/test/test_git.git/description +1 -0
  14. data/test/test_git.git/hooks/applypatch-msg.sample +15 -0
  15. data/test/test_git.git/hooks/commit-msg.sample +24 -0
  16. data/test/test_git.git/hooks/post-commit.sample +8 -0
  17. data/test/test_git.git/hooks/post-receive.sample +15 -0
  18. data/test/test_git.git/hooks/post-update.sample +8 -0
  19. data/test/test_git.git/hooks/pre-applypatch.sample +14 -0
  20. data/test/test_git.git/hooks/pre-commit.sample +46 -0
  21. data/test/test_git.git/hooks/pre-rebase.sample +169 -0
  22. data/test/test_git.git/hooks/prepare-commit-msg.sample +36 -0
  23. data/test/test_git.git/hooks/update.sample +128 -0
  24. data/test/test_git.git/info/exclude +6 -0
  25. data/test/test_git.git/objects/0c/a605e9f0f1d42ce8193ac36db11ec3cc9efc08 +0 -0
  26. data/test/test_git.git/objects/11/bada4e36fd065c8d1d3ca97b8dffa496c8e021 +0 -0
  27. data/test/test_git.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
  28. data/test/test_git.git/objects/88/d4480861346093048e08ce8dcc577d8aa69379 +1 -0
  29. data/test/test_git.git/objects/90/2dce0535b19f0c15ac8407fc4468256ad672d7 +0 -0
  30. data/test/test_git.git/objects/a6/394b3e8a82b76b0dd5b6b317f489dfe22426a6 +0 -0
  31. data/test/test_git.git/objects/a6/5140d5ec9f47064f614ecf8e43776baa5c0c11 +0 -0
  32. data/test/test_git.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  33. data/test/test_git.git/objects/ea/41dba10b54a794284e0be009a11f0ff3716a28 +0 -0
  34. data/test/test_git.git/objects/f5/5f3c44c89e5d215fbaaef9d33563117fe0b61b +1 -0
  35. data/test/test_git.git/objects/ff/1f1d4bd0c99e1c9cca047c46b2194accf89504 +4 -0
  36. data/test/test_git.git/refs/heads/master +1 -0
  37. data/test/test_git.rb +44 -0
  38. metadata +84 -9
@@ -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,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
+ x��Aj�0E��)�i%y,{ �@���3�Qk���(�������Ã�mۖ������P�y�2%�9��dS��r�1&N�w�J %d��Ȃ�*{���@Ȫe�ѣ�{�m;|k����Z���IRm��l���ڶO�����p���x��n�����L]*�րk��DZ�?�|Nd
@@ -0,0 +1 @@
1
+ x���m�0 E{�Z e� E�@/ �I�
@@ -0,0 +1,4 @@
1
+ x��K
2
+ 1]�}���Dܺq� 2������x�����h�0H?x��D�df$i"y�n!��W��d�JN�7��
3
+ �p�u��w�=���RO4��
4
+ !���#D���������%V�e���;�
@@ -0,0 +1 @@
1
+ 0ca605e9f0f1d42ce8193ac36db11ec3cc9efc08
data/test/test_git.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'dandelion/git'
2
+ require 'test/unit'
3
+
4
+ class TestGit < Test::Unit::TestCase
5
+ def setup
6
+ @repo = Dandelion::Git::Repo.new(File.join(File.dirname(__FILE__), 'test_git.git'))
7
+ end
8
+
9
+ def test_tree_files
10
+ tree = Dandelion::Git::Tree.new(@repo, 'HEAD')
11
+ files = ['foo', 'bar', 'baz/foo', 'baz/bar']
12
+ assert_equal files.sort, tree.files.sort
13
+ end
14
+
15
+ def test_tree_show
16
+ tree = Dandelion::Git::Tree.new(@repo, 'HEAD')
17
+ assert_equal "bar\n", tree.show('foo')
18
+ assert_equal "bar\n", tree.show('baz/foo')
19
+ end
20
+
21
+ def test_tree_revision
22
+ revision = 'ff1f1d4bd0c99e1c9cca047c46b2194accf89504'
23
+ tree = Dandelion::Git::Tree.new(@repo, revision)
24
+ assert_equal revision, tree.revision
25
+ end
26
+
27
+ def test_diff_changed
28
+ from = 'ff1f1d4bd0c99e1c9cca047c46b2194accf89504'
29
+ to = '88d4480861346093048e08ce8dcc577d8aa69379'
30
+ files = ['foo', 'baz/foo']
31
+ diff = Dandelion::Git::Diff.new(@repo, from, to)
32
+ assert_equal files.sort, diff.changed.sort
33
+ assert_equal [], diff.deleted
34
+ end
35
+
36
+ def test_diff_deleted
37
+ from = 'f55f3c44c89e5d215fbaaef9d33563117fe0b61b'
38
+ to = '0ca605e9f0f1d42ce8193ac36db11ec3cc9efc08'
39
+ files = ['test_delete']
40
+ diff = Dandelion::Git::Diff.new(@repo, from, to)
41
+ assert_equal files.sort, diff.deleted.sort
42
+ assert_equal [], diff.changed
43
+ end
44
+ end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dandelion
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.7
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
6
10
  platform: ruby
7
11
  authors:
8
12
  - Scott Nelson
@@ -10,7 +14,7 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-03-12 00:00:00 -05:00
17
+ date: 2011-04-17 00:00:00 -04:00
14
18
  default_executable:
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
@@ -21,6 +25,10 @@ dependencies:
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 5
24
32
  version: 2.0.5
25
33
  type: :runtime
26
34
  version_requirements: *id001
@@ -32,10 +40,14 @@ dependencies:
32
40
  requirements:
33
41
  - - ">="
34
42
  - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 4
46
+ - 1
35
47
  version: 2.4.1
36
48
  type: :runtime
37
49
  version_requirements: *id002
38
- description: Git repository deployment via SFTP
50
+ description: Git repository deployment via FTP/SFTP
39
51
  email:
40
52
  - scottbnel@gmail.com
41
53
  executables:
@@ -57,8 +69,38 @@ files:
57
69
  - lib/dandelion/git.rb
58
70
  - lib/dandelion/service.rb
59
71
  - lib/dandelion/version.rb
72
+ - test/fixtures/diff
73
+ - test/fixtures/ls_tree
74
+ - test/test_diff_deployment.rb
75
+ - test/test_git.git/HEAD
76
+ - test/test_git.git/config
77
+ - test/test_git.git/description
78
+ - test/test_git.git/hooks/applypatch-msg.sample
79
+ - test/test_git.git/hooks/commit-msg.sample
80
+ - test/test_git.git/hooks/post-commit.sample
81
+ - test/test_git.git/hooks/post-receive.sample
82
+ - test/test_git.git/hooks/post-update.sample
83
+ - test/test_git.git/hooks/pre-applypatch.sample
84
+ - test/test_git.git/hooks/pre-commit.sample
85
+ - test/test_git.git/hooks/pre-rebase.sample
86
+ - test/test_git.git/hooks/prepare-commit-msg.sample
87
+ - test/test_git.git/hooks/update.sample
88
+ - test/test_git.git/info/exclude
89
+ - test/test_git.git/objects/0c/a605e9f0f1d42ce8193ac36db11ec3cc9efc08
90
+ - test/test_git.git/objects/11/bada4e36fd065c8d1d3ca97b8dffa496c8e021
91
+ - test/test_git.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
92
+ - test/test_git.git/objects/88/d4480861346093048e08ce8dcc577d8aa69379
93
+ - test/test_git.git/objects/90/2dce0535b19f0c15ac8407fc4468256ad672d7
94
+ - test/test_git.git/objects/a6/394b3e8a82b76b0dd5b6b317f489dfe22426a6
95
+ - test/test_git.git/objects/a6/5140d5ec9f47064f614ecf8e43776baa5c0c11
96
+ - test/test_git.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
97
+ - test/test_git.git/objects/ea/41dba10b54a794284e0be009a11f0ff3716a28
98
+ - test/test_git.git/objects/f5/5f3c44c89e5d215fbaaef9d33563117fe0b61b
99
+ - test/test_git.git/objects/ff/1f1d4bd0c99e1c9cca047c46b2194accf89504
100
+ - test/test_git.git/refs/heads/master
101
+ - test/test_git.rb
60
102
  has_rdoc: true
61
- homepage: http://github.com/scottbnel/dandelion
103
+ homepage: http://github.com/scttnlsn/dandelion
62
104
  licenses: []
63
105
 
64
106
  post_install_message:
@@ -71,19 +113,52 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
113
  requirements:
72
114
  - - ">="
73
115
  - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
74
118
  version: "0"
75
119
  required_rubygems_version: !ruby/object:Gem::Requirement
76
120
  none: false
77
121
  requirements:
78
122
  - - ">="
79
123
  - !ruby/object:Gem::Version
124
+ segments:
125
+ - 0
80
126
  version: "0"
81
127
  requirements: []
82
128
 
83
129
  rubyforge_project:
84
- rubygems_version: 1.5.0
130
+ rubygems_version: 1.3.7
85
131
  signing_key:
86
132
  specification_version: 3
87
- summary: dandelion-0.1.7
88
- test_files: []
89
-
133
+ summary: dandelion-0.2.0
134
+ test_files:
135
+ - test/fixtures/diff
136
+ - test/fixtures/ls_tree
137
+ - test/test_diff_deployment.rb
138
+ - test/test_git.git/HEAD
139
+ - test/test_git.git/config
140
+ - test/test_git.git/description
141
+ - test/test_git.git/hooks/applypatch-msg.sample
142
+ - test/test_git.git/hooks/commit-msg.sample
143
+ - test/test_git.git/hooks/post-commit.sample
144
+ - test/test_git.git/hooks/post-receive.sample
145
+ - test/test_git.git/hooks/post-update.sample
146
+ - test/test_git.git/hooks/pre-applypatch.sample
147
+ - test/test_git.git/hooks/pre-commit.sample
148
+ - test/test_git.git/hooks/pre-rebase.sample
149
+ - test/test_git.git/hooks/prepare-commit-msg.sample
150
+ - test/test_git.git/hooks/update.sample
151
+ - test/test_git.git/info/exclude
152
+ - test/test_git.git/objects/0c/a605e9f0f1d42ce8193ac36db11ec3cc9efc08
153
+ - test/test_git.git/objects/11/bada4e36fd065c8d1d3ca97b8dffa496c8e021
154
+ - test/test_git.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
155
+ - test/test_git.git/objects/88/d4480861346093048e08ce8dcc577d8aa69379
156
+ - test/test_git.git/objects/90/2dce0535b19f0c15ac8407fc4468256ad672d7
157
+ - test/test_git.git/objects/a6/394b3e8a82b76b0dd5b6b317f489dfe22426a6
158
+ - test/test_git.git/objects/a6/5140d5ec9f47064f614ecf8e43776baa5c0c11
159
+ - test/test_git.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
160
+ - test/test_git.git/objects/ea/41dba10b54a794284e0be009a11f0ff3716a28
161
+ - test/test_git.git/objects/f5/5f3c44c89e5d215fbaaef9d33563117fe0b61b
162
+ - test/test_git.git/objects/ff/1f1d4bd0c99e1c9cca047c46b2194accf89504
163
+ - test/test_git.git/refs/heads/master
164
+ - test/test_git.rb