git-notary 2.1.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a17c292adcdd3e4821201d5e2c17b642e1c68ea
4
+ data.tar.gz: d4a0c4a561aae9ab080845a686c4b9a02622b031
5
+ SHA512:
6
+ metadata.gz: 5107946ffb9a6803da3abc80790a8eac7fb088ad21323b7fa675ca6330218a3f30797f25a68ec1057b33fd08d9897a65d9d00c425c3cfa0a4d41da37b319dd62
7
+ data.tar.gz: 9090feb3adfd11b1850cf532adca3c82407830789f21035543629c6de5ef0fa55c2419143ad5e35b982b20192d651b6b433f49851da62eee038c39e5b95a02a8
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ auto/**
2
+ *.tex
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+
2
+ The MIT License (MIT)
3
+ Copyright © 2016 Chris Olstrom <chris@olstrom.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.org ADDED
@@ -0,0 +1,127 @@
1
+ #+TITLE: git-notary
2
+ #+SUBTITLE: a versioning experiment for git
3
+ #+LATEX: \pagebreak
4
+
5
+ * Overview
6
+
7
+ ~git-notary~ generates canonical version tags from versioning notes.
8
+
9
+ ** Why would I want this?
10
+
11
+ ~git-notary~ may be helpful if you want to use Semantic Versioning in a project
12
+ with many contributors and some manner of branch-oriented workflow. Tracking
13
+ versioning information with a ~VERSION~ file seems like a great idea, but has
14
+ some quirks.
15
+
16
+ ** An Example Scenario
17
+
18
+ Consider the following (simplified) scenario:
19
+
20
+ #+BEGIN_EXAMPLE
21
+ ,* e44e210 - (HEAD -> develop) Merge branch 'bar' into develop
22
+ |\
23
+ | * e1793f3 - (bar) PATCH
24
+ | * f231d3b - MAJOR
25
+ | * 5c69653 - MAJOR
26
+ ,* | 67543e1 - Merge branch 'foo' into develop
27
+ |\ \
28
+ | |/
29
+ |/|
30
+ | * ea81623 - (foo) MAJOR
31
+ | * 8b773db - PATCH
32
+ | * 6613b79 - MINOR
33
+ |/
34
+ ,* 21c36f3 - (master) MINOR
35
+ ,* 64357c2 - MINOR
36
+ ,* 9ebfd7d - MINOR
37
+ ,* cc5d832 - PATCH
38
+ ,* ebc851f - MINOR
39
+ ,* a75790f - PATCH
40
+ ,* 572a9e8 - MAJOR
41
+ ,* a990127 - (tag: 0.0.0) INITIAL
42
+ #+END_EXAMPLE
43
+
44
+ In this example, two branches (~foo~ and ~bar~) were created from ~master~
45
+ (~21c36f3~). Both branches know that ~1.4.0~ is the latest tag (at the time they
46
+ branched). Let's assume these branches do not conflict with each other.
47
+
48
+ With a ~VERSION~ file, a project generally chooses one of two places to update it:
49
+
50
+ - Updates occur in the branch. In this case, once either branch is merged, the
51
+ other is in conflict with it.
52
+ - Updates occur in the trunk. In this case, the trunk now contains code that did
53
+ not originate in a branch. Again, the first merged is safe, but the other is
54
+ in a conflicting state.
55
+
56
+ If ~foo~ merges first, the expected version post-merge is ~2.0.0~.
57
+
58
+ If ~bar~ merges first, the expected version is ~3.0.1~.
59
+
60
+ At ~e44e210~ (~HEAD~ of ~develop~), the final version should be ~4.0.1~, but if
61
+ the merge order were reversed, it should be ~4.0.0~. This gets worse as the
62
+ number of active branches increases.
63
+
64
+ * Assumptions
65
+
66
+ - Versioning is important.
67
+ - Versions should communicate scope of change.
68
+ - Humans can signal the scope of their own changes.
69
+ - Machines can figure out the rest.
70
+
71
+ * Installation
72
+
73
+ Download the latest release of ~git-notary~ and place it somewhere in your ~$PATH~.
74
+ #+LATEX: \pagebreak
75
+
76
+ * Usage
77
+
78
+ ** Add new versioning information
79
+
80
+ #+BEGIN_SRC shell
81
+ git-notary new <version> [object] [namespace]
82
+ #+END_SRC
83
+
84
+ Where <version> is one of (major, minor, patch).
85
+
86
+ ** Undo a version
87
+
88
+ #+BEGIN_SRC shell
89
+ git-notary undo [object] [namespace]
90
+ #+END_SRC
91
+
92
+ ** Fetch versioning notes
93
+
94
+ #+BEGIN_SRC shell
95
+ git-notary fetch [remote] [namespace]
96
+ #+END_SRC
97
+
98
+ ** Push versioning notes
99
+
100
+ #+BEGIN_SRC shell
101
+ git-notary push [remote] [namespace]
102
+ #+END_SRC
103
+
104
+ ** Extract Notes
105
+
106
+ #+BEGIN_SRC shell
107
+ git-notary notes [branch] [base] [namespace]
108
+ #+END_SRC
109
+
110
+ ** Compute Versions from Notes
111
+
112
+ #+BEGIN_SRC shell
113
+ git-notary notes | git-notary versions [initial]
114
+ #+END_SRC
115
+
116
+ ** Generate Tags from Versions
117
+
118
+ #+BEGIN_SRC shell
119
+ git-notary notes | git-notary versions | git-notary tags [--apply]
120
+ #+END_SRC
121
+
122
+ * License
123
+
124
+ ~git-notary~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full text.
125
+
126
+ * Contributors
127
+ - [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
data/bin/git-notary ADDED
@@ -0,0 +1,245 @@
1
+ #!/bin/sh
2
+
3
+ GIT_NOTARY_VERSION=2.1.3
4
+ GIT_NOTARY_NAMESPACE=${GIT_NOTARY_NAMESPACE:-'versioning'}
5
+
6
+ # notes [branch] [base] [namespace]
7
+ notes() {
8
+ BRANCH=${1-'develop'}
9
+ BASE=${2:-$(git describe --tags --abbrev=0)}
10
+ NAMESPACE=${3:-${GIT_NOTARY_NAMESPACE}}
11
+
12
+ git rev-list --topo-order ${BASE}..${BRANCH} --reverse | while read OBJECT; do
13
+ printf "${OBJECT} "
14
+ git notes --ref=${NAMESPACE} show ${OBJECT} 2> /dev/null || echo
15
+ done | grep -E '(MAJOR|MINOR|PATCH)$'
16
+ }
17
+
18
+ # squash
19
+ squash() {
20
+ while read OBJECT_CHANGE; do
21
+ OBJECT=$(echo ${OBJECT_CHANGE} | awk '{ print $1 }')
22
+ CHANGE=$(echo ${OBJECT_CHANGE} | awk '{ print $2 }')
23
+
24
+ case ${CHANGE} in
25
+ MAJOR)
26
+ RESULT=MAJOR;;
27
+ MINOR)
28
+ test "${RESULT}" != MAJOR && RESULT=MINOR;;
29
+ PATCH)
30
+ test -z "${RESULT}" && RESULT=PATCH;;
31
+ esac
32
+ done
33
+
34
+ test ! -z "${RESULT}" && echo ${OBJECT} ${RESULT}
35
+ }
36
+
37
+ # squeeze <up|down>
38
+ squeeze() {
39
+ case ${1} in
40
+ d|down|f|first|o|old*)
41
+ DIRECTION=DOWN;;
42
+ u|up|l|last|n|new*)
43
+ DIRECTION=UP;;
44
+ *)
45
+ echo 'git-notary squeeze requires a direction (up or down)' >&2
46
+ exit 23;;
47
+ esac
48
+
49
+ while read OBJECT_CHANGE; do
50
+ OBJECT=$(echo ${OBJECT_CHANGE} | awk '{ print $1 }')
51
+ CHANGE=$(echo ${OBJECT_CHANGE} | awk '{ print $2 }')
52
+
53
+ if test "${CHANGE}" != "${LAST_CHANGE}"; then
54
+ case ${DIRECTION} in
55
+ DOWN)
56
+ echo ${OBJECT} ${CHANGE};;
57
+ UP)
58
+ test ! -z "${LAST_OBJECT}" && echo ${LAST_OBJECT} ${LAST_CHANGE};;
59
+ esac
60
+ fi
61
+
62
+ LAST_OBJECT=${OBJECT}
63
+ LAST_CHANGE=${CHANGE}
64
+ done
65
+
66
+ test "${DIRECTION}" = UP && echo ${LAST_OBJECT} ${LAST_CHANGE}
67
+ }
68
+
69
+ # versions [initial]
70
+ versions() {
71
+ set -o errexit
72
+ VERSION=${1:-$(git describe --tags --abbrev=0)}
73
+
74
+ MAJOR=$(echo ${VERSION} | awk -F . '{ print $1 }')
75
+ MINOR=$(echo ${VERSION} | awk -F . '{ print $2 }')
76
+ PATCH=$(echo ${VERSION} | awk -F . '{ print $3 }')
77
+
78
+ next() {
79
+ echo ${1} + 1 | bc
80
+ }
81
+
82
+ while read OBJECT_CHANGE; do
83
+ OBJECT=$(echo ${OBJECT_CHANGE} | awk '{ print $1 }')
84
+ CHANGE=$(echo ${OBJECT_CHANGE} | awk '{ print $2 }')
85
+
86
+ case ${CHANGE} in
87
+ MAJOR)
88
+ MAJOR=$(next ${MAJOR})
89
+ MINOR=0
90
+ PATCH=0
91
+ ;;
92
+ MINOR)
93
+ MINOR=$(next ${MINOR})
94
+ PATCH=0
95
+ ;;
96
+ PATCH)
97
+ PATCH=$(next ${PATCH})
98
+ ;;
99
+ esac
100
+
101
+ VERSION=${MAJOR}.${MINOR}.${PATCH}
102
+ echo ${OBJECT} ${VERSION}
103
+ done
104
+ }
105
+
106
+ # tags [--apply]
107
+ tags() {
108
+ while read OBJECT_TAG; do
109
+ OBJECT=$(echo ${OBJECT_TAG} | awk '{ print $1 }')
110
+ TAG=$(echo ${OBJECT_TAG} | awk '{ print $2 }')
111
+
112
+ if test "${1}" = '--apply'; then
113
+ git tag ${TAG} ${OBJECT}
114
+ else
115
+ echo git tag ${TAG} ${OBJECT}
116
+ fi
117
+ done
118
+ }
119
+
120
+ # fetch [remote] [namespace]
121
+ fetch() {
122
+ REMOTE=${1:-'origin'}
123
+ NAMESPACE=${2:-${GIT_NOTARY_NAMESPACE}}
124
+
125
+ git fetch ${REMOTE} refs/notes/${NAMESPACE}:refs/notes/${NAMESPACE}
126
+ }
127
+
128
+ # push [remote] [namespace]
129
+ push() {
130
+ REMOTE=${1:-'origin'}
131
+ NAMESPACE=${2:-${GIT_NOTARY_NAMESPACE}}
132
+
133
+ git push --no-verify ${REMOTE} refs/notes/${NAMESPACE}
134
+ }
135
+
136
+ # new <major|minor|patch> [object] [namespace]
137
+ new() {
138
+ CHANGE=$(echo ${1} | tr [:lower:] [:upper:])
139
+ OBJECT=${2:-HEAD}
140
+ NAMESPACE=${3:-${GIT_NOTARY_NAMESPACE}}
141
+
142
+ if echo ${CHANGE} | grep -qE '^(MAJOR|MINOR|PATCH)$'; then
143
+ git notes --ref=${NAMESPACE} add --message ${CHANGE} ${OBJECT}
144
+ else
145
+ echo MAJOR MINOR and PATCH are valid. ${CHANGE} is not.
146
+ exit 23
147
+ fi
148
+ }
149
+
150
+ # delta (--squash) [object] [base] [namespace]
151
+ delta() {
152
+ if test "${1}" = '--squash'; then
153
+ SQUASH=true
154
+ shift
155
+ fi
156
+
157
+ OBJECT=${1:-HEAD}
158
+ BASE=${2:-$(git describe --tags --abbrev=0)}
159
+ NAMESPACE=${3:-${GIT_NOTARY_NAMESPACE}}
160
+
161
+ if test "${SQUASH}" = 'true'; then
162
+ NEW=$(git-notary notes ${OBJECT} ${BASE} ${NAMESPACE} | git-notary squash | git-notary versions | awk '{ print $2 }')
163
+ else
164
+ NEW=$(git-notary notes ${OBJECT} ${BASE} ${NAMESPACE} | git-notary versions | tail -1 | awk '{ print $2 }')
165
+ fi
166
+
167
+ LATEST_TAG_ON_BASE=$(git describe --tags --abbrev=0 ${BASE})
168
+ OLD=${LATEST_TAG_ON_BASE:-'0.0.0'}
169
+ echo "${OLD} -> ${NEW}"
170
+ }
171
+
172
+ # undo [object] [namespace]
173
+ undo() {
174
+ OBJECT=${1:-HEAD}
175
+ NAMESPACE=${2:-${GIT_NOTARY_NAMESPACE}}
176
+
177
+ git notes --ref=${NAMESPACE} remove ${OBJECT}
178
+ }
179
+
180
+ # version
181
+ version() {
182
+ echo "git-notary ${GIT_NOTARY_VERSION}"
183
+ }
184
+
185
+ # help
186
+ help() {
187
+ cat <<EOF
188
+ $(version)
189
+ usage:
190
+ git-notary new <major|minor|patch> [object] [namespace]
191
+ git-notary undo [object] [namespace]
192
+ git-notary delta [--squash] [object] [base] [namespace]
193
+
194
+ git-notary fetch [remote] [namespace]
195
+ git-notary push [remote] [namespace]
196
+
197
+ git-notary notes [branch] [base] [namespace]
198
+ git-notary versions [initial]
199
+ git-notary tags [--apply]
200
+ EOF
201
+ }
202
+
203
+ # notary <command> [args]
204
+ notary() {
205
+ COMMAND=${1}
206
+ shift
207
+ case ${COMMAND} in
208
+ N|notes)
209
+ notes ${@};;
210
+ V|versions)
211
+ versions ${@};;
212
+ T|tags)
213
+ tags ${@};;
214
+ S|squash)
215
+ squash ${@};;
216
+ Z|squeeze)
217
+ squeeze ${@};;
218
+ n|new)
219
+ new ${@};;
220
+ u|undo)
221
+ undo ${@};;
222
+ d|delta)
223
+ delta ${@};;
224
+ P|push)
225
+ push ${@};;
226
+ f|fetch)
227
+ fetch ${@};;
228
+ M|major)
229
+ new MAJOR ${@};;
230
+ m|minor)
231
+ new MINOR ${@};;
232
+ p|patch)
233
+ new PATCH ${@};;
234
+ v|version|-v|--version)
235
+ version;;
236
+ h|help|-h|--help)
237
+ help;;
238
+ *)
239
+ help
240
+ exit 1
241
+ ;;
242
+ esac
243
+ }
244
+
245
+ notary ${@}
@@ -0,0 +1,11 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'git-notary'
3
+ gem.version = `git describe --tags --abbrev=0`.chomp
4
+ gem.license = 'MIT'
5
+ gem.author = 'Chris Olstrom'
6
+ gem.email = 'chris@olstrom.com'
7
+ gem.homepage = 'https://github.com/colstrom/git-notary'
8
+ gem.summary = 'generates canonical version tags from versioning notes'
9
+ gem.files = `git ls-files`.split("\n")
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
11
+ end
data/hooks/pre-commit ADDED
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ while read LOCAL_REF LOCAL_SHA REMOTE_REF REMOTE_SHA; do
4
+ if git-notary notes ${LOCAL_SHA} develop > /dev/null; then
5
+ BRANCH_HAS_NOTES=true
6
+ else
7
+ BRANCH_HAS_NOTES=false
8
+ break
9
+ fi
10
+ done
11
+
12
+ test ${BRANCH_HAS_NOTES} = true
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-notary
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Chris Olstrom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: chris@olstrom.com
15
+ executables:
16
+ - git-notary
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - LICENSE.txt
22
+ - README.org
23
+ - bin/git-notary
24
+ - git-notary.gemspec
25
+ - hooks/pre-commit
26
+ homepage: https://github.com/colstrom/git-notary
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.5.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: generates canonical version tags from versioning notes
50
+ test_files: []
51
+ has_rdoc: