karmi-markout 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +18 -3
- data/VERSION.yml +1 -1
- data/lib/markout/formatters/html/templates/common/code.css +1 -1
- data/lib/markout/formatters/html/templates/default/content.rhtml +1 -0
- data/lib/markout/formatters/html/templates/default/screen.css +15 -3
- data/lib/markout/revision.rb +13 -2
- metadata +13 -65
- data/test/fixtures/empty.txt +0 -0
- data/test/fixtures/empty_repository__dot__git/COMMIT_EDITMSG +0 -12
- data/test/fixtures/empty_repository__dot__git/HEAD +0 -1
- data/test/fixtures/empty_repository__dot__git/config +0 -6
- data/test/fixtures/empty_repository__dot__git/description +0 -1
- data/test/fixtures/empty_repository__dot__git/hooks/applypatch-msg.sample +0 -15
- data/test/fixtures/empty_repository__dot__git/hooks/commit-msg.sample +0 -24
- data/test/fixtures/empty_repository__dot__git/hooks/post-commit.sample +0 -8
- data/test/fixtures/empty_repository__dot__git/hooks/post-receive.sample +0 -15
- data/test/fixtures/empty_repository__dot__git/hooks/post-update.sample +0 -8
- data/test/fixtures/empty_repository__dot__git/hooks/pre-applypatch.sample +0 -14
- data/test/fixtures/empty_repository__dot__git/hooks/pre-commit.sample +0 -18
- data/test/fixtures/empty_repository__dot__git/hooks/pre-rebase.sample +0 -169
- data/test/fixtures/empty_repository__dot__git/hooks/prepare-commit-msg.sample +0 -36
- data/test/fixtures/empty_repository__dot__git/hooks/update.sample +0 -107
- data/test/fixtures/empty_repository__dot__git/index +0 -0
- data/test/fixtures/empty_repository__dot__git/info/exclude +0 -6
- data/test/fixtures/empty_repository__dot__git/logs/HEAD +0 -1
- data/test/fixtures/empty_repository__dot__git/logs/refs/heads/master +0 -1
- data/test/fixtures/empty_repository__dot__git/objects/25/877ea00eb8d2de7a31cf7c4c4c16f0390d48fd +0 -0
- data/test/fixtures/empty_repository__dot__git/objects/a0/b6af2541dce8f646276ec7340695c34c7578aa +0 -0
- data/test/fixtures/empty_repository__dot__git/objects/ec/9e2a7b50ee2dfd5e6f8b5224fb3d7a98a79558 +0 -0
- data/test/fixtures/empty_repository__dot__git/refs/heads/master +0 -1
- data/test/fixtures/markdown.html +0 -839
- data/test/fixtures/markdown.txt +0 -235
- data/test/fixtures/mt_textformat_menu.png +0 -0
data/README.rdoc
CHANGED
@@ -4,19 +4,34 @@ Markout makes it easy to export sexy formatted documents such as specifications
|
|
4
4
|
|
5
5
|
Designed for easy extending, theming and adding output formats.
|
6
6
|
|
7
|
-
|
7
|
+
Work in progress.
|
8
8
|
|
9
9
|
|
10
10
|
== Usage
|
11
11
|
|
12
|
-
|
12
|
+
Installation:
|
13
13
|
|
14
14
|
$ sudo gem install karmi-markout --source=http://gems.github.com
|
15
15
|
|
16
|
+
Converting Markdown file with history to an HTML file in the same location as source:
|
17
|
+
|
18
|
+
$ markout -h /path/to/your/file.txt
|
19
|
+
|
20
|
+
More information:
|
21
|
+
|
22
|
+
$ markout --help
|
23
|
+
|
16
24
|
|
17
25
|
== Todo
|
18
26
|
|
19
|
-
|
27
|
+
* Cleanup Git-related code
|
28
|
+
* Add test coverage
|
29
|
+
* Embedded Sinatra app for more lush display of everything on the server
|
30
|
+
* More flexibility in Git features
|
31
|
+
* Cleaner PDF dependencies
|
32
|
+
* Setting-up remote Git repo and post-receive hooks with simple Rake tasks
|
33
|
+
* Notifications on new revision pushes
|
34
|
+
|
20
35
|
|
21
36
|
== Copyright
|
22
37
|
|
data/VERSION.yml
CHANGED
@@ -41,6 +41,7 @@
|
|
41
41
|
<div id="revision_<%= revision.sha %>" class="revision">
|
42
42
|
<h4><%= revision.date.strftime('%d/%m/%Y %H:%M') %> : <%= revision.subject %> (<%= revision.author %>)</h4>
|
43
43
|
<div class="detail">
|
44
|
+
<% if revision.message %><%= revision.message(:format => :html) %><% end %>
|
44
45
|
<pre>
|
45
46
|
<code class="diff">
|
46
47
|
<%= revision.diff(:format => 'inline') %>
|
@@ -80,8 +80,10 @@ h3 {
|
|
80
80
|
color: #172533;
|
81
81
|
font-size: 1.1em;
|
82
82
|
font-weight:bold;
|
83
|
-
margin: 1.8em 0 0.25em 0;
|
84
83
|
letter-spacing:-1px;
|
84
|
+
padding: 1em 0 0 0;
|
85
|
+
margin: 1.8em 0 0.25em 0;
|
86
|
+
border-top: 1px solid #d8dde3;
|
85
87
|
}
|
86
88
|
|
87
89
|
h3 a {
|
@@ -120,6 +122,9 @@ pre {
|
|
120
122
|
|
121
123
|
hr { display: none; }
|
122
124
|
|
125
|
+
ul { list-style-type: square; margin: 0.5em 0 1em 0; padding-left: 1.5em; }
|
126
|
+
ul li { margin-left: 0em; }
|
127
|
+
|
123
128
|
#history {
|
124
129
|
margin-bottom: 2em;
|
125
130
|
}
|
@@ -158,10 +163,14 @@ hr { display: none; }
|
|
158
163
|
}
|
159
164
|
|
160
165
|
#history .revision .detail {
|
161
|
-
margin: 0
|
166
|
+
margin: 0 0.8em 0 0.8em;
|
162
167
|
padding: 0;
|
163
168
|
}
|
164
169
|
|
170
|
+
#history .revision .detail p {
|
171
|
+
font-size: 95%;
|
172
|
+
}
|
173
|
+
|
165
174
|
#history .revision pre {
|
166
175
|
background: none;
|
167
176
|
line-height: 120%;
|
@@ -170,6 +179,9 @@ hr { display: none; }
|
|
170
179
|
padding: 0 1em 0 1em;
|
171
180
|
}
|
172
181
|
|
182
|
+
#history .revision pre {
|
183
|
+
margin: 0 0.1em 0 0.1em;
|
184
|
+
}
|
173
185
|
#history .revision code {
|
174
186
|
margin: 0;
|
175
187
|
padding: 0;
|
@@ -184,5 +196,5 @@ hr { display: none; }
|
|
184
196
|
#history .diff del,
|
185
197
|
#history .diff .del {
|
186
198
|
color: red;
|
187
|
-
text-decoration:
|
199
|
+
text-decoration: line-through;
|
188
200
|
}
|
data/lib/markout/revision.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'rdiscount'
|
2
|
+
|
1
3
|
module Markout
|
2
4
|
|
3
5
|
class Revision
|
4
6
|
|
5
|
-
attr_reader :sha, :date, :author, :subject
|
7
|
+
attr_reader :sha, :date, :author, :subject
|
6
8
|
|
7
9
|
def initialize(repo, commit)
|
8
10
|
@repo = repo
|
@@ -22,10 +24,19 @@ module Markout
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
def message(options={})
|
28
|
+
case options[:format]
|
29
|
+
when :html
|
30
|
+
return RDiscount.new(@message).to_html
|
31
|
+
else
|
32
|
+
return @message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
private
|
26
37
|
|
27
38
|
def parse_commit_message(commit)
|
28
|
-
lines = commit.message.split("
|
39
|
+
lines = commit.message.split("\n")
|
29
40
|
[ lines.first, lines[1..commit.message.size].join("\n") ]
|
30
41
|
end
|
31
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karmi-markout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-13 00:00:00 -07:00
|
13
13
|
default_executable: markout
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -49,91 +49,32 @@ executables:
|
|
49
49
|
extensions: []
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
|
-
- README.rdoc
|
53
52
|
- LICENSE
|
53
|
+
- README.rdoc
|
54
54
|
files:
|
55
55
|
- README.rdoc
|
56
56
|
- VERSION.yml
|
57
|
-
-
|
58
|
-
- lib/markout
|
57
|
+
- lib/markout.rb
|
59
58
|
- lib/markout/document.rb
|
60
59
|
- lib/markout/formatter.rb
|
61
|
-
- lib/markout/formatters
|
62
|
-
- lib/markout/formatters/html
|
63
60
|
- lib/markout/formatters/html/html.rb
|
64
|
-
- lib/markout/formatters/html/templates
|
65
|
-
- lib/markout/formatters/html/templates/common
|
66
61
|
- lib/markout/formatters/html/templates/common/application.js
|
67
62
|
- lib/markout/formatters/html/templates/common/code.css
|
68
63
|
- lib/markout/formatters/html/templates/common/code_highlighter.js
|
69
64
|
- lib/markout/formatters/html/templates/common/jquery-1.3.2.min.js
|
70
65
|
- lib/markout/formatters/html/templates/common/syntax_diff.js
|
71
|
-
- lib/markout/formatters/html/templates/default
|
72
66
|
- lib/markout/formatters/html/templates/default/content.rhtml
|
73
67
|
- lib/markout/formatters/html/templates/default/print.css
|
74
68
|
- lib/markout/formatters/html/templates/default/screen.css
|
75
|
-
- lib/markout/formatters/pdf
|
76
69
|
- lib/markout/formatters/pdf/pdf.rb
|
77
70
|
- lib/markout/history.rb
|
78
71
|
- lib/markout/output.rb
|
79
72
|
- lib/markout/revision.rb
|
80
|
-
- lib/markout.rb
|
81
|
-
- test/fixtures
|
82
|
-
- test/fixtures/empty.txt
|
83
|
-
- test/fixtures/empty_repository__dot__git
|
84
|
-
- test/fixtures/empty_repository__dot__git/COMMIT_EDITMSG
|
85
|
-
- test/fixtures/empty_repository__dot__git/config
|
86
|
-
- test/fixtures/empty_repository__dot__git/description
|
87
|
-
- test/fixtures/empty_repository__dot__git/HEAD
|
88
|
-
- test/fixtures/empty_repository__dot__git/hooks
|
89
|
-
- test/fixtures/empty_repository__dot__git/hooks/applypatch-msg.sample
|
90
|
-
- test/fixtures/empty_repository__dot__git/hooks/commit-msg.sample
|
91
|
-
- test/fixtures/empty_repository__dot__git/hooks/post-commit.sample
|
92
|
-
- test/fixtures/empty_repository__dot__git/hooks/post-receive.sample
|
93
|
-
- test/fixtures/empty_repository__dot__git/hooks/post-update.sample
|
94
|
-
- test/fixtures/empty_repository__dot__git/hooks/pre-applypatch.sample
|
95
|
-
- test/fixtures/empty_repository__dot__git/hooks/pre-commit.sample
|
96
|
-
- test/fixtures/empty_repository__dot__git/hooks/pre-rebase.sample
|
97
|
-
- test/fixtures/empty_repository__dot__git/hooks/prepare-commit-msg.sample
|
98
|
-
- test/fixtures/empty_repository__dot__git/hooks/update.sample
|
99
|
-
- test/fixtures/empty_repository__dot__git/index
|
100
|
-
- test/fixtures/empty_repository__dot__git/info
|
101
|
-
- test/fixtures/empty_repository__dot__git/info/exclude
|
102
|
-
- test/fixtures/empty_repository__dot__git/logs
|
103
|
-
- test/fixtures/empty_repository__dot__git/logs/HEAD
|
104
|
-
- test/fixtures/empty_repository__dot__git/logs/refs
|
105
|
-
- test/fixtures/empty_repository__dot__git/logs/refs/heads
|
106
|
-
- test/fixtures/empty_repository__dot__git/logs/refs/heads/master
|
107
|
-
- test/fixtures/empty_repository__dot__git/objects
|
108
|
-
- test/fixtures/empty_repository__dot__git/objects/25
|
109
|
-
- test/fixtures/empty_repository__dot__git/objects/25/877ea00eb8d2de7a31cf7c4c4c16f0390d48fd
|
110
|
-
- test/fixtures/empty_repository__dot__git/objects/a0
|
111
|
-
- test/fixtures/empty_repository__dot__git/objects/a0/b6af2541dce8f646276ec7340695c34c7578aa
|
112
|
-
- test/fixtures/empty_repository__dot__git/objects/ec
|
113
|
-
- test/fixtures/empty_repository__dot__git/objects/ec/9e2a7b50ee2dfd5e6f8b5224fb3d7a98a79558
|
114
|
-
- test/fixtures/empty_repository__dot__git/objects/info
|
115
|
-
- test/fixtures/empty_repository__dot__git/objects/pack
|
116
|
-
- test/fixtures/empty_repository__dot__git/refs
|
117
|
-
- test/fixtures/empty_repository__dot__git/refs/heads
|
118
|
-
- test/fixtures/empty_repository__dot__git/refs/heads/master
|
119
|
-
- test/fixtures/empty_repository__dot__git/refs/tags
|
120
|
-
- test/fixtures/markdown.html
|
121
|
-
- test/fixtures/markdown.txt
|
122
|
-
- test/fixtures/mt_textformat_menu.png
|
123
|
-
- test/markout_document_test.rb
|
124
|
-
- test/markout_formatter_test.rb
|
125
|
-
- test/markout_history_test.rb
|
126
|
-
- test/markout_html_test.rb
|
127
|
-
- test/markout_output_test.rb
|
128
|
-
- test/markout_revision_test.rb
|
129
|
-
- test/markout_test.rb
|
130
|
-
- test/test_helper.rb
|
131
73
|
- LICENSE
|
132
74
|
has_rdoc: true
|
133
75
|
homepage: http://github.com/karmi/markout
|
134
76
|
post_install_message:
|
135
77
|
rdoc_options:
|
136
|
-
- --inline-source
|
137
78
|
- --charset=UTF-8
|
138
79
|
require_paths:
|
139
80
|
- lib
|
@@ -156,5 +97,12 @@ rubygems_version: 1.2.0
|
|
156
97
|
signing_key:
|
157
98
|
specification_version: 2
|
158
99
|
summary: Sexy Markdown output
|
159
|
-
test_files:
|
160
|
-
|
100
|
+
test_files:
|
101
|
+
- test/markout_document_test.rb
|
102
|
+
- test/markout_formatter_test.rb
|
103
|
+
- test/markout_history_test.rb
|
104
|
+
- test/markout_html_test.rb
|
105
|
+
- test/markout_output_test.rb
|
106
|
+
- test/markout_revision_test.rb
|
107
|
+
- test/markout_test.rb
|
108
|
+
- test/test_helper.rb
|
data/test/fixtures/empty.txt
DELETED
File without changes
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Initial commit to empty repository
|
2
|
-
# Please enter the commit message for your changes. Lines starting
|
3
|
-
# with '#' will be ignored, and an empty message aborts the commit.
|
4
|
-
# On branch master
|
5
|
-
#
|
6
|
-
# Initial commit
|
7
|
-
#
|
8
|
-
# Changes to be committed:
|
9
|
-
# (use "git rm --cached <file>..." to unstage)
|
10
|
-
#
|
11
|
-
# new file: .gitignore
|
12
|
-
#
|
@@ -1 +0,0 @@
|
|
1
|
-
ref: refs/heads/master
|
@@ -1 +0,0 @@
|
|
1
|
-
Unnamed repository; edit this file to name it for gitweb.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# An example hook script to check the commit log message taken by
|
4
|
-
# applypatch from an e-mail message.
|
5
|
-
#
|
6
|
-
# The hook should exit with non-zero status after issuing an
|
7
|
-
# appropriate message if it wants to stop the commit. The hook is
|
8
|
-
# allowed to edit the commit message file.
|
9
|
-
#
|
10
|
-
# To enable this hook, rename this file to "applypatch-msg".
|
11
|
-
|
12
|
-
. git-sh-setup
|
13
|
-
test -x "$GIT_DIR/hooks/commit-msg" &&
|
14
|
-
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
|
15
|
-
:
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# An example hook script to check the commit log message.
|
4
|
-
# Called by git-commit with one argument, the name of the file
|
5
|
-
# that has the commit message. The hook should exit with non-zero
|
6
|
-
# status after issuing an appropriate message if it wants to stop the
|
7
|
-
# commit. The hook is allowed to edit the commit message file.
|
8
|
-
#
|
9
|
-
# To enable this hook, rename this file to "commit-msg".
|
10
|
-
|
11
|
-
# Uncomment the below to add a Signed-off-by line to the message.
|
12
|
-
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
13
|
-
# hook is more suited to it.
|
14
|
-
#
|
15
|
-
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
16
|
-
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
17
|
-
|
18
|
-
# This example catches duplicate Signed-off-by lines.
|
19
|
-
|
20
|
-
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
21
|
-
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
22
|
-
echo >&2 Duplicate Signed-off-by lines.
|
23
|
-
exit 1
|
24
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# An example hook script for the "post-receive" event.
|
4
|
-
#
|
5
|
-
# The "post-receive" script is run after receive-pack has accepted a pack
|
6
|
-
# and the repository has been updated. It is passed arguments in through
|
7
|
-
# stdin in the form
|
8
|
-
# <oldrev> <newrev> <refname>
|
9
|
-
# For example:
|
10
|
-
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
|
11
|
-
#
|
12
|
-
# see contrib/hooks/ for an sample, or uncomment the next line and
|
13
|
-
# rename the file to "post-receive".
|
14
|
-
|
15
|
-
#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# An example hook script to verify what is about to be committed
|
4
|
-
# by applypatch from an e-mail message.
|
5
|
-
#
|
6
|
-
# The hook should exit with non-zero status after issuing an
|
7
|
-
# appropriate message if it wants to stop the commit.
|
8
|
-
#
|
9
|
-
# To enable this hook, rename this file to "pre-applypatch".
|
10
|
-
|
11
|
-
. git-sh-setup
|
12
|
-
test -x "$GIT_DIR/hooks/pre-commit" &&
|
13
|
-
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
|
14
|
-
:
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# An example hook script to verify what is about to be committed.
|
4
|
-
# Called by git-commit with no arguments. The hook should
|
5
|
-
# exit with non-zero status after issuing an appropriate message if
|
6
|
-
# it wants to stop the commit.
|
7
|
-
#
|
8
|
-
# To enable this hook, rename this file to "pre-commit".
|
9
|
-
|
10
|
-
if git-rev-parse --verify HEAD 2>/dev/null
|
11
|
-
then
|
12
|
-
against=HEAD
|
13
|
-
else
|
14
|
-
# Initial commit: diff against an empty tree object
|
15
|
-
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
16
|
-
fi
|
17
|
-
|
18
|
-
exec git diff-index --check --cached $against --
|
@@ -1,169 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# Copyright (c) 2006, 2008 Junio C Hamano
|
4
|
-
#
|
5
|
-
# The "pre-rebase" hook is run just before "git-rebase" starts doing
|
6
|
-
# its job, and can prevent the command from running by exiting with
|
7
|
-
# non-zero status.
|
8
|
-
#
|
9
|
-
# The hook is called with the following parameters:
|
10
|
-
#
|
11
|
-
# $1 -- the upstream the series was forked from.
|
12
|
-
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
13
|
-
#
|
14
|
-
# This sample shows how to prevent topic branches that are already
|
15
|
-
# merged to 'next' branch from getting rebased, because allowing it
|
16
|
-
# would result in rebasing already published history.
|
17
|
-
|
18
|
-
publish=next
|
19
|
-
basebranch="$1"
|
20
|
-
if test "$#" = 2
|
21
|
-
then
|
22
|
-
topic="refs/heads/$2"
|
23
|
-
else
|
24
|
-
topic=`git symbolic-ref HEAD` ||
|
25
|
-
exit 0 ;# we do not interrupt rebasing detached HEAD
|
26
|
-
fi
|
27
|
-
|
28
|
-
case "$topic" in
|
29
|
-
refs/heads/??/*)
|
30
|
-
;;
|
31
|
-
*)
|
32
|
-
exit 0 ;# we do not interrupt others.
|
33
|
-
;;
|
34
|
-
esac
|
35
|
-
|
36
|
-
# Now we are dealing with a topic branch being rebased
|
37
|
-
# on top of master. Is it OK to rebase it?
|
38
|
-
|
39
|
-
# Does the topic really exist?
|
40
|
-
git show-ref -q "$topic" || {
|
41
|
-
echo >&2 "No such branch $topic"
|
42
|
-
exit 1
|
43
|
-
}
|
44
|
-
|
45
|
-
# Is topic fully merged to master?
|
46
|
-
not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
|
47
|
-
if test -z "$not_in_master"
|
48
|
-
then
|
49
|
-
echo >&2 "$topic is fully merged to master; better remove it."
|
50
|
-
exit 1 ;# we could allow it, but there is no point.
|
51
|
-
fi
|
52
|
-
|
53
|
-
# Is topic ever merged to next? If so you should not be rebasing it.
|
54
|
-
only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
|
55
|
-
only_next_2=`git-rev-list ^master ${publish} | sort`
|
56
|
-
if test "$only_next_1" = "$only_next_2"
|
57
|
-
then
|
58
|
-
not_in_topic=`git-rev-list "^$topic" master`
|
59
|
-
if test -z "$not_in_topic"
|
60
|
-
then
|
61
|
-
echo >&2 "$topic is already up-to-date with master"
|
62
|
-
exit 1 ;# we could allow it, but there is no point.
|
63
|
-
else
|
64
|
-
exit 0
|
65
|
-
fi
|
66
|
-
else
|
67
|
-
not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
|
68
|
-
perl -e '
|
69
|
-
my $topic = $ARGV[0];
|
70
|
-
my $msg = "* $topic has commits already merged to public branch:\n";
|
71
|
-
my (%not_in_next) = map {
|
72
|
-
/^([0-9a-f]+) /;
|
73
|
-
($1 => 1);
|
74
|
-
} split(/\n/, $ARGV[1]);
|
75
|
-
for my $elem (map {
|
76
|
-
/^([0-9a-f]+) (.*)$/;
|
77
|
-
[$1 => $2];
|
78
|
-
} split(/\n/, $ARGV[2])) {
|
79
|
-
if (!exists $not_in_next{$elem->[0]}) {
|
80
|
-
if ($msg) {
|
81
|
-
print STDERR $msg;
|
82
|
-
undef $msg;
|
83
|
-
}
|
84
|
-
print STDERR " $elem->[1]\n";
|
85
|
-
}
|
86
|
-
}
|
87
|
-
' "$topic" "$not_in_next" "$not_in_master"
|
88
|
-
exit 1
|
89
|
-
fi
|
90
|
-
|
91
|
-
exit 0
|
92
|
-
|
93
|
-
################################################################
|
94
|
-
|
95
|
-
This sample hook safeguards topic branches that have been
|
96
|
-
published from being rewound.
|
97
|
-
|
98
|
-
The workflow assumed here is:
|
99
|
-
|
100
|
-
* Once a topic branch forks from "master", "master" is never
|
101
|
-
merged into it again (either directly or indirectly).
|
102
|
-
|
103
|
-
* Once a topic branch is fully cooked and merged into "master",
|
104
|
-
it is deleted. If you need to build on top of it to correct
|
105
|
-
earlier mistakes, a new topic branch is created by forking at
|
106
|
-
the tip of the "master". This is not strictly necessary, but
|
107
|
-
it makes it easier to keep your history simple.
|
108
|
-
|
109
|
-
* Whenever you need to test or publish your changes to topic
|
110
|
-
branches, merge them into "next" branch.
|
111
|
-
|
112
|
-
The script, being an example, hardcodes the publish branch name
|
113
|
-
to be "next", but it is trivial to make it configurable via
|
114
|
-
$GIT_DIR/config mechanism.
|
115
|
-
|
116
|
-
With this workflow, you would want to know:
|
117
|
-
|
118
|
-
(1) ... if a topic branch has ever been merged to "next". Young
|
119
|
-
topic branches can have stupid mistakes you would rather
|
120
|
-
clean up before publishing, and things that have not been
|
121
|
-
merged into other branches can be easily rebased without
|
122
|
-
affecting other people. But once it is published, you would
|
123
|
-
not want to rewind it.
|
124
|
-
|
125
|
-
(2) ... if a topic branch has been fully merged to "master".
|
126
|
-
Then you can delete it. More importantly, you should not
|
127
|
-
build on top of it -- other people may already want to
|
128
|
-
change things related to the topic as patches against your
|
129
|
-
"master", so if you need further changes, it is better to
|
130
|
-
fork the topic (perhaps with the same name) afresh from the
|
131
|
-
tip of "master".
|
132
|
-
|
133
|
-
Let's look at this example:
|
134
|
-
|
135
|
-
o---o---o---o---o---o---o---o---o---o "next"
|
136
|
-
/ / / /
|
137
|
-
/ a---a---b A / /
|
138
|
-
/ / / /
|
139
|
-
/ / c---c---c---c B /
|
140
|
-
/ / / \ /
|
141
|
-
/ / / b---b C \ /
|
142
|
-
/ / / / \ /
|
143
|
-
---o---o---o---o---o---o---o---o---o---o---o "master"
|
144
|
-
|
145
|
-
|
146
|
-
A, B and C are topic branches.
|
147
|
-
|
148
|
-
* A has one fix since it was merged up to "next".
|
149
|
-
|
150
|
-
* B has finished. It has been fully merged up to "master" and "next",
|
151
|
-
and is ready to be deleted.
|
152
|
-
|
153
|
-
* C has not merged to "next" at all.
|
154
|
-
|
155
|
-
We would want to allow C to be rebased, refuse A, and encourage
|
156
|
-
B to be deleted.
|
157
|
-
|
158
|
-
To compute (1):
|
159
|
-
|
160
|
-
git-rev-list ^master ^topic next
|
161
|
-
git-rev-list ^master next
|
162
|
-
|
163
|
-
if these match, topic has not merged in next at all.
|
164
|
-
|
165
|
-
To compute (2):
|
166
|
-
|
167
|
-
git-rev-list master..topic
|
168
|
-
|
169
|
-
if this is empty, it is fully merged to "master".
|