githug 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/LICENCE.txt +22 -0
  2. data/README.md +39 -30
  3. data/levels/add.rb +2 -1
  4. data/levels/bisect.rb +1 -1
  5. data/levels/blame/config.rb +1 -1
  6. data/levels/branch_at.rb +1 -1
  7. data/levels/commit_amend.rb +1 -1
  8. data/levels/config.rb +2 -2
  9. data/levels/ignore.rb +5 -1
  10. data/levels/log.rb +2 -2
  11. data/levels/merge.rb +1 -1
  12. data/levels/merge_squash.rb +4 -4
  13. data/levels/rm.rb +1 -1
  14. data/levels/stash/.githug/COMMIT_EDITMSG +1 -0
  15. data/levels/stash/.githug/HEAD +1 -0
  16. data/levels/stash/.githug/config +7 -0
  17. data/levels/stash/.githug/description +1 -0
  18. data/levels/stash/.githug/hooks/applypatch-msg.sample +15 -0
  19. data/levels/stash/.githug/hooks/commit-msg.sample +24 -0
  20. data/levels/stash/.githug/hooks/post-update.sample +8 -0
  21. data/levels/stash/.githug/hooks/pre-applypatch.sample +14 -0
  22. data/levels/stash/.githug/hooks/pre-commit.sample +50 -0
  23. data/levels/stash/.githug/hooks/pre-rebase.sample +169 -0
  24. data/levels/stash/.githug/hooks/prepare-commit-msg.sample +36 -0
  25. data/levels/stash/.githug/hooks/update.sample +128 -0
  26. data/levels/stash/.githug/index +0 -0
  27. data/levels/stash/.githug/info/exclude +6 -0
  28. data/levels/stash/.githug/logs/HEAD +1 -0
  29. data/levels/stash/.githug/logs/refs/heads/master +1 -0
  30. data/levels/stash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
  31. data/levels/stash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  32. data/levels/stash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
  33. data/levels/stash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
  34. data/levels/stash/.githug/refs/heads/master +1 -0
  35. data/levels/stash/lyrics.txt +13 -0
  36. data/levels/stash.rb +16 -0
  37. data/levels/status.rb +1 -1
  38. data/lib/githug/cli.rb +2 -2
  39. data/lib/githug/game.rb +1 -1
  40. data/lib/githug/level.rb +14 -12
  41. data/lib/githug/profile.rb +1 -1
  42. data/lib/githug/repository.rb +3 -3
  43. data/lib/githug/ui.rb +6 -15
  44. data/lib/githug/version.rb +1 -1
  45. data/spec/githug/cli_spec.rb +11 -11
  46. data/spec/githug/game_spec.rb +6 -6
  47. data/spec/githug/level_spec.rb +17 -17
  48. data/spec/githug/profile_spec.rb +4 -4
  49. data/spec/githug/repository_spec.rb +14 -14
  50. data/spec/githug/ui_spec.rb +13 -11
  51. data/spec/githug_spec.rb +242 -0
  52. metadata +93 -55
data/LICENCE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Gary 'Gazler' Rennie
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -49,43 +49,48 @@ Githug has a DSL for writing levels
49
49
 
50
50
  An example level:
51
51
 
52
- difficulty 1
53
- description "There is a file in your folder called README, you should add it to your staging area"
54
-
55
- setup do
56
- repo.init
57
- FileUtils.touch("README")
58
- end
59
-
60
- solution do
61
- return false unless repo.status.files.keys.include?("README")
62
- return false if repo.status.files["README"].untracked
63
- true
64
- end
65
-
66
- hint do
67
- puts "You can type `git` in your shell to get a list of available git commands"
68
- end
52
+ ```ruby
53
+ difficulty 1
54
+ description "There is a file in your folder called README, you should add it to your staging area"
55
+
56
+ setup do
57
+ repo.init
58
+ FileUtils.touch("README")
59
+ end
60
+
61
+ solution do
62
+ return false unless repo.status.files.keys.include?("README")
63
+ return false if repo.status.files["README"].untracked
64
+ true
65
+ end
66
+
67
+ hint do
68
+ puts "You can type `git` in your shell to get a list of available git commands"
69
+ end
70
+ ```
69
71
 
70
72
  `difficulty`, `description` and `solution` are required.
71
73
 
72
74
  You can also include multiple hints like this:
73
75
 
74
- hints [
75
- "You can type `git` in your shell to get a list of available git commands",
76
- "Check the man for `git add`"]
76
+ ```ruby
77
+ hints [
78
+ "You can type `git` in your shell to get a list of available git commands",
79
+ "Check the man for `git add`"]
80
+ ```
77
81
 
78
82
  **note** Because `solution` is a Proc, you cannot prematurely return out of it and as a result, must put an explicit return on the last line of the solution block.
79
83
 
80
-
81
- solution do
82
- solved = false
83
- solved = true if repo.valid?
84
- solved
85
- end
84
+ ```ruby
85
+ solution do
86
+ solved = false
87
+ solved = true if repo.valid?
88
+ solved
89
+ end
90
+ ```
86
91
 
87
92
  By default, `setup` will remove all files from the game folder. You do not need to include a setup method if you don't want an initial git repository (if you are testing `git init` or only checking an answer.)
88
-
93
+
89
94
  You can call `repo.init` to initialize an empty repository.
90
95
 
91
96
  All methods called on `repo` are sent to the [grit gem](https://github.com/mojombo/grit) if the method does not exist, and you can use that for most git related commands (`repo.add`, `repo.commit`, etc.)
@@ -93,9 +98,11 @@ You can also include multiple hints like this:
93
98
 
94
99
  Another method exists called `init_from_level` and it is used like so:
95
100
 
96
- setup do
97
- init_from_level
98
- end
101
+ ```ruby
102
+ setup do
103
+ init_from_level
104
+ end
105
+ ```
99
106
 
100
107
  This will copy the contents of a repository specified in the levels folder for your level. For example, if your level is called "merge" then it will copy the contents of the "merge" folder. it is recommended that you do the following steps:
101
108
 
@@ -119,3 +126,5 @@ The easiest way to test a level is:
119
126
  * Run `githug test PATH_TO_YOUR_LEVEL
120
127
 
121
128
  Please note that the `githug test` command can be run as `githug test --errors` to get an error stacktrace from your solve method.
129
+
130
+ It would be ideal if you add an integration test for your level. These tests live in `spec/githug_spec` and **must** be run in order. If you add a level but do not add a test, please add a simple `skip_level` test case similar to the `contribute` level.
data/levels/add.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  difficulty 1
2
- description "There is a file in your folder called README, you should add it to your staging area"
2
+ description "There is a file in your folder called README, you should add it to your staging area
3
+ Note: You start each level with a new repo. Don't look for files from the previous one"
3
4
 
4
5
  setup do
5
6
  repo.init
data/levels/bisect.rb CHANGED
@@ -11,5 +11,5 @@ solution do
11
11
  end
12
12
 
13
13
  hint do
14
- puts ["The fastest way to find the bug is with bisect.", "Start bisect with a good and bad commit, then run git bisect run make test."]
14
+ puts ["The fastest way to find the bug is with bisect.", "Don't forget to start bisect first, identify a good or bad commit, then run git bisect run make test."]
15
15
  end
@@ -3,7 +3,7 @@ class Config
3
3
  def initialize(name, password = nil, options = {})
4
4
  @name = name
5
5
  @password = password || "i<3evil"
6
-
6
+
7
7
  if options[:downcase]
8
8
  @name.downcase!
9
9
  end
data/levels/branch_at.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  difficulty 3
2
- description "You forgot to branch at the previous commit and made a commit on top of it. Create branch 'test_branch' at the commit before the last"
2
+ description "You forgot to branch at the previous commit and made a commit on top of it. Create branch 'test_branch' at the commit before the last"
3
3
 
4
4
  setup do
5
5
  repo.init
@@ -13,7 +13,7 @@ solution do
13
13
  # Reset config - see issue #74
14
14
  file = File.open(".git/config", "w") do |file|
15
15
  file.puts("[format]")
16
- file.puts(" pretty = medium")
16
+ file.puts(" pretty = medium")
17
17
  end
18
18
  repo.commits.length == 1 && Grit::CommitStats.find_all(repo, repo.commits.first.sha).first[1].files.length == 2
19
19
  end
data/levels/config.rb CHANGED
@@ -8,8 +8,8 @@ end
8
8
  solution do
9
9
 
10
10
  valid = false
11
-
12
- name = request("What is your name?")
11
+
12
+ name = request("What is your name?")
13
13
  email = request("What is your email?")
14
14
  config_name = repo.config["user.name"]
15
15
  config_email = repo.config["user.email"]
data/levels/ignore.rb CHANGED
@@ -3,12 +3,16 @@ description "The text editor 'vim' creates files ending in .swp (swap files) for
3
3
 
4
4
  setup do
5
5
  repo.init
6
+ FileUtils.touch("README.swp")
7
+ file = File.open(".git/config", "w") do |file|
8
+ file.puts "[core]\nexcludesfile="
9
+ end
6
10
  end
7
11
 
8
12
  solution do
9
13
 
10
14
  valid = false
11
-
15
+
12
16
 
13
17
  File.open(".gitignore", "r") do |file|
14
18
  while line = file.gets
data/levels/log.rb CHANGED
@@ -4,13 +4,13 @@ description "You will be asked for the first 7 chars of the hash of most recent
4
4
 
5
5
  setup do
6
6
  repo.init
7
- file = File.new("newfile.rb", "w")
7
+ file = File.new("newfile.rb", "w")
8
8
  repo.add("newfile.rb")
9
9
  repo.commit_all("THIS IS THE COMMIT YOU ARE LOOKING FOR!")
10
10
  end
11
11
 
12
12
  solution do
13
- repo.commits.last.id_abbrev == request("What are the first 7 characters of the hash of the most recent commit?")
13
+ repo.commits.last.id_abbrev == request("What are the first 7 characters of the hash of the most recent commit?")
14
14
  end
15
15
 
16
16
  hint do
data/levels/merge.rb CHANGED
@@ -6,7 +6,7 @@ setup do
6
6
  end
7
7
 
8
8
  solution do
9
- File.exists?("file1") && File.exists?("file2")
9
+ File.exists?("file1") && File.exists?("file2")
10
10
  end
11
11
 
12
12
  hint do
@@ -20,9 +20,9 @@ setup do
20
20
  File.open("file3", 'a') { |f| f << "and awesomer!\n" }
21
21
  repo.add "file3"
22
22
  repo.commit_all "Time"
23
-
23
+
24
24
  repo.git.native :checkout, {}, 'master'
25
-
25
+
26
26
  FileUtils.touch "file2"
27
27
  repo.add "file2"
28
28
  repo.commit_all "Second commit"
@@ -33,13 +33,13 @@ solution do
33
33
 
34
34
  # Check the number of commits in the repo (should be 4 - including initial .gitignore).
35
35
  result = false unless repo.commits.size == 3
36
-
36
+
37
37
  # Check if changes from all the commits from long-feature-branch are included.
38
38
  file = File.open('file3')
39
39
  result = false unless file.readline =~ /some feature/
40
40
  result = false unless file.readline =~ /getting awesomer/
41
41
  result = false unless file.readline =~ /and awesomer!/
42
-
42
+
43
43
  result
44
44
  end
45
45
 
data/levels/rm.rb CHANGED
@@ -4,7 +4,7 @@ description "A file has been removed from the working tree, however the file was
4
4
 
5
5
  setup do
6
6
  repo.init
7
- file = File.new("deleteme.rb", "w")
7
+ file = File.new("deleteme.rb", "w")
8
8
  file.close
9
9
  repo.add("deleteme.rb")
10
10
  repo.commit_all("Added a temp file")
@@ -0,0 +1 @@
1
+ Add some lyrics
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1,7 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = false
5
+ logallrefupdates = true
6
+ ignorecase = true
7
+ precomposeunicode = false
@@ -0,0 +1 @@
1
+ Unnamed repository; edit this file 'description' to name the repository.
@@ -0,0 +1,15 @@
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
+ :
@@ -0,0 +1,24 @@
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
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to prepare a packed repository for use over
4
+ # dumb transports.
5
+ #
6
+ # To enable this hook, rename this file to "post-update".
7
+
8
+ exec git update-server-info
@@ -0,0 +1,14 @@
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
+ :
@@ -0,0 +1,50 @@
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 >/dev/null 2>&1
11
+ then
12
+ against=HEAD
13
+ else
14
+ # Initial commit: diff against an empty tree object
15
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
16
+ fi
17
+
18
+ # If you want to allow non-ascii filenames set this variable to true.
19
+ allownonascii=$(git config hooks.allownonascii)
20
+
21
+ # Redirect output to stderr.
22
+ exec 1>&2
23
+
24
+ # Cross platform projects tend to avoid non-ascii filenames; prevent
25
+ # them from being added to the repository. We exploit the fact that the
26
+ # printable range starts at the space character and ends with tilde.
27
+ if [ "$allownonascii" != "true" ] &&
28
+ # Note that the use of brackets around a tr range is ok here, (it's
29
+ # even required, for portability to Solaris 10's /usr/bin/tr), since
30
+ # the square bracket bytes happen to fall in the designated range.
31
+ test $(git diff --cached --name-only --diff-filter=A -z $against |
32
+ LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
33
+ then
34
+ echo "Error: Attempt to add a non-ascii file name."
35
+ echo
36
+ echo "This can cause problems if you want to work"
37
+ echo "with people on other platforms."
38
+ echo
39
+ echo "To be portable it is advisable to rename the file ..."
40
+ echo
41
+ echo "If you know what you are doing you can disable this"
42
+ echo "check using:"
43
+ echo
44
+ echo " git config hooks.allownonascii true"
45
+ echo
46
+ exit 1
47
+ fi
48
+
49
+ # If there are whitespace errors, print the offending file names and fail.
50
+ exec git diff-index --check --cached $against --
@@ -0,0 +1,169 @@
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
+ /usr/bin/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".
@@ -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"