Browse Source

sample feed

Brennen Bearnes 5 years ago
parent
commit
d2507f5c18
1 changed files with 843 additions and 0 deletions
  1. 843
    0
      sample_feed.xml

+ 843
- 0
sample_feed.xml View File

@@ -0,0 +1,843 @@
1
+<?xml version="1.0" encoding="us-ascii"?>
2
+<feed xmlns="http://www.w3.org/2005/Atom"><title>git-feed: a script to generate Atom feeds for git commit logs </title><link href="https://github.com/brennen/git-feed/"/><link href="https://raw.githubusercontent.com/brennen/git-feed/master/sample_feed.xml" rel="self"/><author><name>Brennen Bearnes</name></author><id>https://github.com/brennen/git-feed/</id><generator>XML::Atom::SimpleFeed</generator><updated>2014-10-28T06:01:58Z</updated><entry><title>be less clever about return value</title><link href="https://github.com/brennen/git-feed/"/><id>4ebb36290858e8d4dcdc39f98cbdac8a676e332f</id><content type="html">&lt;pre&gt;commit 4ebb36290858e8d4dcdc39f98cbdac8a676e332f
3
+Author: Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
4
+Date:   Tue Oct 28 05:54:09 2014 -0600
5
+
6
+    be less clever about return value
7
+
8
+diff --git a/git-feed b/git-feed
9
+index 191480d..d31f6b6 100755
10
+--- a/git-feed
11
++++ b/git-feed
12
+@@ -21,9 +21,9 @@ the feed itself).
13
+ It can be configured for a given repository by doing something like the
14
+ following:
15
+ 
16
+-  git config feed.projecturl https://p1k3.com/userland-book/
17
+-  git config feed.url https://p1k3.com/userland-book/feed.xml
18
+-  echo &#38;#39;userland: a book about the command line for human beings&#38;#39; &#38;gt; .git/description
19
++    git config feed.projecturl https://p1k3.com/userland-book/
20
++    git config feed.url https://p1k3.com/userland-book/feed.xml
21
++    echo &#38;#39;userland: a book about the command line for human beings&#38;#39; &#38;gt; .git/description
22
+ 
23
+ I have I&#38;lt;no idea&#38;gt; whether this sort of thing is considered an acceptable use of 
24
+ git configuration, but it seems to work.
25
+@@ -74,7 +74,7 @@ user.name.
26
+ 
27
+ =head1 EXAMPLES
28
+ 
29
+-    git feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
30
++    git-feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
31
+ 
32
+ =head1 INSTALLING
33
+ 
34
+@@ -90,6 +90,11 @@ or:
35
+ ...depending on which one gave me less static on a given system.  I don&#38;#39;t
36
+ really know what I&#38;#39;m doing in the Perl ecosystem any more, though.
37
+ 
38
++Anyway, if you put git-feed in your path, you can probably invoke it like
39
++any other git subcommand:
40
++
41
++    git feed &#38;gt; feed.xml
42
++
43
+ =head1 AUTHOR
44
+ 
45
+ Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
46
+@@ -221,4 +226,5 @@ sub git_config {
47
+   my ($key) = @_;
48
+   my $value = capturex([0,1], &#38;#39;git&#38;#39;, &#38;#39;config&#38;#39;, &#38;#39;--get&#38;#39;, $key);
49
+   chomp($value);
50
++  return $value;
51
+ }
52
+&lt;/pre&gt;</content><updated>2014-10-28 05:54:09 -0600</updated></entry><entry><title>some TODO-ish comments</title><link href="https://github.com/brennen/git-feed/"/><id>e1b06c25923a6344e964a5d2de047d2009ac94a2</id><content type="html">&lt;pre&gt;commit e1b06c25923a6344e964a5d2de047d2009ac94a2
53
+Author: Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
54
+Date:   Tue Oct 28 05:37:21 2014 -0600
55
+
56
+    some TODO-ish comments
57
+
58
+diff --git a/git-feed b/git-feed
59
+index 056d4b2..191480d 100755
60
+--- a/git-feed
61
++++ b/git-feed
62
+@@ -108,9 +108,14 @@ use XML::Atom::SimpleFeed;
63
+ use HTML::Entities;
64
+ use Getopt::Long;
65
+ use POSIX qw(strftime);
66
++
67
++# Turns out to be pretty much exactly what I want for system calls:
68
+ use IPC::System::Simple qw(capturex);
69
+ 
70
+-# Figure out where top-level .git resides:
71
++# Figure out where top-level .git/ resides.  Naturally, &#38;quot;rev-parse&#38;quot; was the
72
++# first command that leapt to mind when I wondered if there was a builtin way
73
++# to ask that question.  I mean, what kind of loser would have had to google
74
++# something so _blindingly obvious_?
75
+ my $repo_base = git(&#38;#39;rev-parse&#38;#39;, &#38;#39;--show-toplevel&#38;#39;);
76
+ chomp($repo_base);
77
+ 
78
+@@ -156,7 +161,7 @@ my $feed = XML::Atom::SimpleFeed-&#38;gt;new(
79
+   id        =&#38;gt; $project_link,
80
+   generator =&#38;gt; &#38;#39;XML::Atom::SimpleFeed&#38;#39;,
81
+ 
82
+-  # this could be better - just uses current time, at the moment:
83
++  # This could be better - just uses current time, at the moment:
84
+   updated   =&#38;gt; iso_date(time()),
85
+ );
86
+ 
87
+@@ -167,6 +172,12 @@ while ($log =~ m/^([a-z0-9]+) _ (.*) _ (.*)$/gm) {
88
+   my $date = $2;
89
+   my $subj = $3;
90
+ 
91
++  # Right now, this doesn&#38;#39;t do anything clever with links for individual
92
++  # commits.  That&#38;#39;s because I&#38;#39;m mostly using it for things that are single
93
++  # HTML files, so it doesn&#38;#39;t seem to matter much.  It would probably be smart
94
++  # to let users specify a different base path for these so they can link
95
++  # GitHub or what-have-you.
96
++
97
+   $feed-&#38;gt;add_entry(
98
+     title     =&#38;gt; $subj,
99
+     link      =&#38;gt; $project_link,
100
+@@ -183,7 +194,8 @@ sub iso_date {
101
+   return strftime(&#38;quot;%Y-%m-%dT%H:%M:%SZ&#38;quot;, localtime($time));
102
+ }
103
+ 
104
+-# get the contents of a file
105
++# Get contents of a file as a string, because a File::Slurp dependency seemed
106
++# like overkill:
107
+ sub slurp {
108
+   my ($file) = @_;
109
+   my $everything;
110
+@@ -196,14 +208,15 @@ sub slurp {
111
+   $everything = &#38;lt;$fh&#38;gt;;
112
+ 
113
+   close $fh
114
+-    or die &#38;quot;Couldn&#38;#39;t close: $!&#38;quot;;
115
++    or die &#38;quot;Couldn&#38;#39;t close $file: $!&#38;quot;;
116
+ 
117
+   return $everything;
118
+ }
119
+ 
120
+-# run git with some options, return result
121
++# Run git with some options, return result:
122
+ sub git { capturex(&#38;#39;git&#38;#39;, @_); }
123
+ 
124
++# Return a git config value - will be an empty string for unset values:
125
+ sub git_config {
126
+   my ($key) = @_;
127
+   my $value = capturex([0,1], &#38;#39;git&#38;#39;, &#38;#39;config&#38;#39;, &#38;#39;--get&#38;#39;, $key);
128
+&lt;/pre&gt;</content><updated>2014-10-28 05:37:21 -0600</updated></entry><entry><title>better docs</title><link href="https://github.com/brennen/git-feed/"/><id>7cc1ab1ffb28783e36cd881ef21525ee53c9777e</id><content type="html">&lt;pre&gt;commit 7cc1ab1ffb28783e36cd881ef21525ee53c9777e
129
+Author: Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
130
+Date:   Tue Oct 28 05:10:18 2014 -0600
131
+
132
+    better docs
133
+
134
+diff --git a/README.pod b/README.pod
135
+index d18a96c..6a196e0 100644
136
+--- a/README.pod
137
++++ b/README.pod
138
+@@ -10,6 +10,24 @@ git-feed [ B&#38;lt;--project_url=...&#38;gt; ]
139
+ 
140
+ =head1 DESCRIPTION
141
+ 
142
++I keep a lot of projects in git, and I like to provide feeds for things I&#38;#39;m
143
++working on.  This script wraps git and XML::Atom::SimpleFeed to generate a
144
++basic Atom feed of commits.  It tries to use information already available in
145
++the environment, but needs to be given a URL for your project (and probably for
146
++the feed itself).
147
++
148
++It can be configured for a given repository by doing something like the
149
++following:
150
++
151
++  git config feed.projecturl https://p1k3.com/userland-book/
152
++  git config feed.url https://p1k3.com/userland-book/feed.xml
153
++  echo &#38;#39;userland: a book about the command line for human beings&#38;#39; &#38;gt; .git/description
154
++
155
++I have I&#38;lt;no idea&#38;gt; whether this sort of thing is considered an acceptable use of 
156
++git configuration, but it seems to work.
157
++
158
++...or you can supply various options on the command line.
159
++
160
+ B&#38;lt;--project_url=...&#38;gt;
161
+ 
162
+ =over
163
+@@ -56,6 +74,20 @@ user.name.
164
+ 
165
+     git feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
166
+ 
167
++=head1 INSTALLING
168
++
169
++I&#38;#39;ll wrap this in a module and add a build script.  For now, install
170
++XML::Atom::SimpleFeed first.  I would probably do that either with:
171
++
172
++    cpanp -i XML::Atom::SimpleFeed
173
++
174
++or:
175
++
176
++    apt-get install libxml-atom-simplefeed-perl
177
++
178
++...depending on which one gave me less static on a given system.  I don&#38;#39;t
179
++really know what I&#38;#39;m doing in the Perl ecosystem any more, though.
180
++
181
+ =head1 AUTHOR
182
+ 
183
+ Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
184
+diff --git a/git-feed b/git-feed
185
+index 2c0299e..056d4b2 100755
186
+--- a/git-feed
187
++++ b/git-feed
188
+@@ -12,6 +12,24 @@ git-feed [ B&#38;lt;--project_url=...&#38;gt; ]
189
+ 
190
+ =head1 DESCRIPTION
191
+ 
192
++I keep a lot of projects in git, and I like to provide feeds for things I&#38;#39;m
193
++working on.  This script wraps git and XML::Atom::SimpleFeed to generate a
194
++basic Atom feed of commits.  It tries to use information already available in
195
++the environment, but needs to be given a URL for your project (and probably for
196
++the feed itself).
197
++
198
++It can be configured for a given repository by doing something like the
199
++following:
200
++
201
++  git config feed.projecturl https://p1k3.com/userland-book/
202
++  git config feed.url https://p1k3.com/userland-book/feed.xml
203
++  echo &#38;#39;userland: a book about the command line for human beings&#38;#39; &#38;gt; .git/description
204
++
205
++I have I&#38;lt;no idea&#38;gt; whether this sort of thing is considered an acceptable use of 
206
++git configuration, but it seems to work.
207
++
208
++...or you can supply various options on the command line.
209
++
210
+ B&#38;lt;--project_url=...&#38;gt;
211
+ 
212
+ =over
213
+@@ -58,6 +76,20 @@ user.name.
214
+ 
215
+     git feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
216
+ 
217
++=head1 INSTALLING
218
++
219
++I&#38;#39;ll wrap this in a module and add a build script.  For now, install
220
++XML::Atom::SimpleFeed first.  I would probably do that either with:
221
++
222
++    cpanp -i XML::Atom::SimpleFeed
223
++
224
++or:
225
++
226
++    apt-get install libxml-atom-simplefeed-perl
227
++
228
++...depending on which one gave me less static on a given system.  I don&#38;#39;t
229
++really know what I&#38;#39;m doing in the Perl ecosystem any more, though.
230
++
231
+ =head1 AUTHOR
232
+ 
233
+ Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
234
+&lt;/pre&gt;</content><updated>2014-10-28 05:10:18 -0600</updated></entry><entry><title>initial commit - import from userland-book</title><link href="https://github.com/brennen/git-feed/"/><id>870fa5d2310044f7de62172a861017c1256df9f8</id><content type="html">&lt;pre&gt;commit 870fa5d2310044f7de62172a861017c1256df9f8
235
+Author: Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
236
+Date:   Tue Oct 28 04:51:03 2014 -0600
237
+
238
+    initial commit - import from userland-book
239
+
240
+diff --git a/COPYING b/COPYING
241
+new file mode 100644
242
+index 0000000..d511905
243
+--- /dev/null
244
++++ b/COPYING
245
+@@ -0,0 +1,339 @@
246
++		    GNU GENERAL PUBLIC LICENSE
247
++		       Version 2, June 1991
248
++
249
++ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
250
++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
251
++ Everyone is permitted to copy and distribute verbatim copies
252
++ of this license document, but changing it is not allowed.
253
++
254
++			    Preamble
255
++
256
++  The licenses for most software are designed to take away your
257
++freedom to share and change it.  By contrast, the GNU General Public
258
++License is intended to guarantee your freedom to share and change free
259
++software--to make sure the software is free for all its users.  This
260
++General Public License applies to most of the Free Software
261
++Foundation&#38;#39;s software and to any other program whose authors commit to
262
++using it.  (Some other Free Software Foundation software is covered by
263
++the GNU Lesser General Public License instead.)  You can apply it to
264
++your programs, too.
265
++
266
++  When we speak of free software, we are referring to freedom, not
267
++price.  Our General Public Licenses are designed to make sure that you
268
++have the freedom to distribute copies of free software (and charge for
269
++this service if you wish), that you receive source code or can get it
270
++if you want it, that you can change the software or use pieces of it
271
++in new free programs; and that you know you can do these things.
272
++
273
++  To protect your rights, we need to make restrictions that forbid
274
++anyone to deny you these rights or to ask you to surrender the rights.
275
++These restrictions translate to certain responsibilities for you if you
276
++distribute copies of the software, or if you modify it.
277
++
278
++  For example, if you distribute copies of such a program, whether
279
++gratis or for a fee, you must give the recipients all the rights that
280
++you have.  You must make sure that they, too, receive or can get the
281
++source code.  And you must show them these terms so they know their
282
++rights.
283
++
284
++  We protect your rights with two steps: (1) copyright the software, and
285
++(2) offer you this license which gives you legal permission to copy,
286
++distribute and/or modify the software.
287
++
288
++  Also, for each author&#38;#39;s protection and ours, we want to make certain
289
++that everyone understands that there is no warranty for this free
290
++software.  If the software is modified by someone else and passed on, we
291
++want its recipients to know that what they have is not the original, so
292
++that any problems introduced by others will not reflect on the original
293
++authors&#38;#39; reputations.
294
++
295
++  Finally, any free program is threatened constantly by software
296
++patents.  We wish to avoid the danger that redistributors of a free
297
++program will individually obtain patent licenses, in effect making the
298
++program proprietary.  To prevent this, we have made it clear that any
299
++patent must be licensed for everyone&#38;#39;s free use or not licensed at all.
300
++
301
++  The precise terms and conditions for copying, distribution and
302
++modification follow.
303
++
304
++		    GNU GENERAL PUBLIC LICENSE
305
++   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
306
++
307
++  0. This License applies to any program or other work which contains
308
++a notice placed by the copyright holder saying it may be distributed
309
++under the terms of this General Public License.  The &#38;quot;Program&#38;quot;, below,
310
++refers to any such program or work, and a &#38;quot;work based on the Program&#38;quot;
311
++means either the Program or any derivative work under copyright law:
312
++that is to say, a work containing the Program or a portion of it,
313
++either verbatim or with modifications and/or translated into another
314
++language.  (Hereinafter, translation is included without limitation in
315
++the term &#38;quot;modification&#38;quot;.)  Each licensee is addressed as &#38;quot;you&#38;quot;.
316
++
317
++Activities other than copying, distribution and modification are not
318
++covered by this License; they are outside its scope.  The act of
319
++running the Program is not restricted, and the output from the Program
320
++is covered only if its contents constitute a work based on the
321
++Program (independent of having been made by running the Program).
322
++Whether that is true depends on what the Program does.
323
++
324
++  1. You may copy and distribute verbatim copies of the Program&#38;#39;s
325
++source code as you receive it, in any medium, provided that you
326
++conspicuously and appropriately publish on each copy an appropriate
327
++copyright notice and disclaimer of warranty; keep intact all the
328
++notices that refer to this License and to the absence of any warranty;
329
++and give any other recipients of the Program a copy of this License
330
++along with the Program.
331
++
332
++You may charge a fee for the physical act of transferring a copy, and
333
++you may at your option offer warranty protection in exchange for a fee.
334
++
335
++  2. You may modify your copy or copies of the Program or any portion
336
++of it, thus forming a work based on the Program, and copy and
337
++distribute such modifications or work under the terms of Section 1
338
++above, provided that you also meet all of these conditions:
339
++
340
++    a) You must cause the modified files to carry prominent notices
341
++    stating that you changed the files and the date of any change.
342
++
343
++    b) You must cause any work that you distribute or publish, that in
344
++    whole or in part contains or is derived from the Program or any
345
++    part thereof, to be licensed as a whole at no charge to all third
346
++    parties under the terms of this License.
347
++
348
++    c) If the modified program normally reads commands interactively
349
++    when run, you must cause it, when started running for such
350
++    interactive use in the most ordinary way, to print or display an
351
++    announcement including an appropriate copyright notice and a
352
++    notice that there is no warranty (or else, saying that you provide
353
++    a warranty) and that users may redistribute the program under
354
++    these conditions, and telling the user how to view a copy of this
355
++    License.  (Exception: if the Program itself is interactive but
356
++    does not normally print such an announcement, your work based on
357
++    the Program is not required to print an announcement.)
358
++
359
++These requirements apply to the modified work as a whole.  If
360
++identifiable sections of that work are not derived from the Program,
361
++and can be reasonably considered independent and separate works in
362
++themselves, then this License, and its terms, do not apply to those
363
++sections when you distribute them as separate works.  But when you
364
++distribute the same sections as part of a whole which is a work based
365
++on the Program, the distribution of the whole must be on the terms of
366
++this License, whose permissions for other licensees extend to the
367
++entire whole, and thus to each and every part regardless of who wrote it.
368
++
369
++Thus, it is not the intent of this section to claim rights or contest
370
++your rights to work written entirely by you; rather, the intent is to
371
++exercise the right to control the distribution of derivative or
372
++collective works based on the Program.
373
++
374
++In addition, mere aggregation of another work not based on the Program
375
++with the Program (or with a work based on the Program) on a volume of
376
++a storage or distribution medium does not bring the other work under
377
++the scope of this License.
378
++
379
++  3. You may copy and distribute the Program (or a work based on it,
380
++under Section 2) in object code or executable form under the terms of
381
++Sections 1 and 2 above provided that you also do one of the following:
382
++
383
++    a) Accompany it with the complete corresponding machine-readable
384
++    source code, which must be distributed under the terms of Sections
385
++    1 and 2 above on a medium customarily used for software interchange; or,
386
++
387
++    b) Accompany it with a written offer, valid for at least three
388
++    years, to give any third party, for a charge no more than your
389
++    cost of physically performing source distribution, a complete
390
++    machine-readable copy of the corresponding source code, to be
391
++    distributed under the terms of Sections 1 and 2 above on a medium
392
++    customarily used for software interchange; or,
393
++
394
++    c) Accompany it with the information you received as to the offer
395
++    to distribute corresponding source code.  (This alternative is
396
++    allowed only for noncommercial distribution and only if you
397
++    received the program in object code or executable form with such
398
++    an offer, in accord with Subsection b above.)
399
++
400
++The source code for a work means the preferred form of the work for
401
++making modifications to it.  For an executable work, complete source
402
++code means all the source code for all modules it contains, plus any
403
++associated interface definition files, plus the scripts used to
404
++control compilation and installation of the executable.  However, as a
405
++special exception, the source code distributed need not include
406
++anything that is normally distributed (in either source or binary
407
++form) with the major components (compiler, kernel, and so on) of the
408
++operating system on which the executable runs, unless that component
409
++itself accompanies the executable.
410
++
411
++If distribution of executable or object code is made by offering
412
++access to copy from a designated place, then offering equivalent
413
++access to copy the source code from the same place counts as
414
++distribution of the source code, even though third parties are not
415
++compelled to copy the source along with the object code.
416
++
417
++  4. You may not copy, modify, sublicense, or distribute the Program
418
++except as expressly provided under this License.  Any attempt
419
++otherwise to copy, modify, sublicense or distribute the Program is
420
++void, and will automatically terminate your rights under this License.
421
++However, parties who have received copies, or rights, from you under
422
++this License will not have their licenses terminated so long as such
423
++parties remain in full compliance.
424
++
425
++  5. You are not required to accept this License, since you have not
426
++signed it.  However, nothing else grants you permission to modify or
427
++distribute the Program or its derivative works.  These actions are
428
++prohibited by law if you do not accept this License.  Therefore, by
429
++modifying or distributing the Program (or any work based on the
430
++Program), you indicate your acceptance of this License to do so, and
431
++all its terms and conditions for copying, distributing or modifying
432
++the Program or works based on it.
433
++
434
++  6. Each time you redistribute the Program (or any work based on the
435
++Program), the recipient automatically receives a license from the
436
++original licensor to copy, distribute or modify the Program subject to
437
++these terms and conditions.  You may not impose any further
438
++restrictions on the recipients&#38;#39; exercise of the rights granted herein.
439
++You are not responsible for enforcing compliance by third parties to
440
++this License.
441
++
442
++  7. If, as a consequence of a court judgment or allegation of patent
443
++infringement or for any other reason (not limited to patent issues),
444
++conditions are imposed on you (whether by court order, agreement or
445
++otherwise) that contradict the conditions of this License, they do not
446
++excuse you from the conditions of this License.  If you cannot
447
++distribute so as to satisfy simultaneously your obligations under this
448
++License and any other pertinent obligations, then as a consequence you
449
++may not distribute the Program at all.  For example, if a patent
450
++license would not permit royalty-free redistribution of the Program by
451
++all those who receive copies directly or indirectly through you, then
452
++the only way you could satisfy both it and this License would be to
453
++refrain entirely from distribution of the Program.
454
++
455
++If any portion of this section is held invalid or unenforceable under
456
++any particular circumstance, the balance of the section is intended to
457
++apply and the section as a whole is intended to apply in other
458
++circumstances.
459
++
460
++It is not the purpose of this section to induce you to infringe any
461
++patents or other property right claims or to contest validity of any
462
++such claims; this section has the sole purpose of protecting the
463
++integrity of the free software distribution system, which is
464
++implemented by public license practices.  Many people have made
465
++generous contributions to the wide range of software distributed
466
++through that system in reliance on consistent application of that
467
++system; it is up to the author/donor to decide if he or she is willing
468
++to distribute software through any other system and a licensee cannot
469
++impose that choice.
470
++
471
++This section is intended to make thoroughly clear what is believed to
472
++be a consequence of the rest of this License.
473
++
474
++  8. If the distribution and/or use of the Program is restricted in
475
++certain countries either by patents or by copyrighted interfaces, the
476
++original copyright holder who places the Program under this License
477
++may add an explicit geographical distribution limitation excluding
478
++those countries, so that distribution is permitted only in or among
479
++countries not thus excluded.  In such case, this License incorporates
480
++the limitation as if written in the body of this License.
481
++
482
++  9. The Free Software Foundation may publish revised and/or new versions
483
++of the General Public License from time to time.  Such new versions will
484
++be similar in spirit to the present version, but may differ in detail to
485
++address new problems or concerns.
486
++
487
++Each version is given a distinguishing version number.  If the Program
488
++specifies a version number of this License which applies to it and &#38;quot;any
489
++later version&#38;quot;, you have the option of following the terms and conditions
490
++either of that version or of any later version published by the Free
491
++Software Foundation.  If the Program does not specify a version number of
492
++this License, you may choose any version ever published by the Free Software
493
++Foundation.
494
++
495
++  10. If you wish to incorporate parts of the Program into other free
496
++programs whose distribution conditions are different, write to the author
497
++to ask for permission.  For software which is copyrighted by the Free
498
++Software Foundation, write to the Free Software Foundation; we sometimes
499
++make exceptions for this.  Our decision will be guided by the two goals
500
++of preserving the free status of all derivatives of our free software and
501
++of promoting the sharing and reuse of software generally.
502
++
503
++			    NO WARRANTY
504
++
505
++  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
506
++FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
507
++OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
508
++PROVIDE THE PROGRAM &#38;quot;AS IS&#38;quot; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
509
++OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
510
++MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
511
++TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
512
++PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
513
++REPAIR OR CORRECTION.
514
++
515
++  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
516
++WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
517
++REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
518
++INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
519
++OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
520
++TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
521
++YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
522
++PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
523
++POSSIBILITY OF SUCH DAMAGES.
524
++
525
++		     END OF TERMS AND CONDITIONS
526
++
527
++	    How to Apply These Terms to Your New Programs
528
++
529
++  If you develop a new program, and you want it to be of the greatest
530
++possible use to the public, the best way to achieve this is to make it
531
++free software which everyone can redistribute and change under these terms.
532
++
533
++  To do so, attach the following notices to the program.  It is safest
534
++to attach them to the start of each source file to most effectively
535
++convey the exclusion of warranty; and each file should have at least
536
++the &#38;quot;copyright&#38;quot; line and a pointer to where the full notice is found.
537
++
538
++    &#38;lt;one line to give the program&#38;#39;s name and a brief idea of what it does.&#38;gt;
539
++    Copyright (C) &#38;lt;year&#38;gt;  &#38;lt;name of author&#38;gt;
540
++
541
++    This program is free software; you can redistribute it and/or modify
542
++    it under the terms of the GNU General Public License as published by
543
++    the Free Software Foundation; either version 2 of the License, or
544
++    (at your option) any later version.
545
++
546
++    This program is distributed in the hope that it will be useful,
547
++    but WITHOUT ANY WARRANTY; without even the implied warranty of
548
++    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
549
++    GNU General Public License for more details.
550
++
551
++    You should have received a copy of the GNU General Public License along
552
++    with this program; if not, write to the Free Software Foundation, Inc.,
553
++    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
554
++
555
++Also add information on how to contact you by electronic and paper mail.
556
++
557
++If the program is interactive, make it output a short notice like this
558
++when it starts in an interactive mode:
559
++
560
++    Gnomovision version 69, Copyright (C) year name of author
561
++    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w&#38;#39;.
562
++    This is free software, and you are welcome to redistribute it
563
++    under certain conditions; type `show c&#38;#39; for details.
564
++
565
++The hypothetical commands `show w&#38;#39; and `show c&#38;#39; should show the appropriate
566
++parts of the General Public License.  Of course, the commands you use may
567
++be called something other than `show w&#38;#39; and `show c&#38;#39;; they could even be
568
++mouse-clicks or menu items--whatever suits your program.
569
++
570
++You should also get your employer (if you work as a programmer) or your
571
++school, if any, to sign a &#38;quot;copyright disclaimer&#38;quot; for the program, if
572
++necessary.  Here is a sample; alter the names:
573
++
574
++  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
575
++  `Gnomovision&#38;#39; (which makes passes at compilers) written by James Hacker.
576
++
577
++  &#38;lt;signature of Ty Coon&#38;gt;, 1 April 1989
578
++  Ty Coon, President of Vice
579
++
580
++This General Public License does not permit incorporating your program into
581
++proprietary programs.  If your program is a subroutine library, you may
582
++consider it more useful to permit linking proprietary applications with the
583
++library.  If this is what you want to do, use the GNU Lesser General
584
++Public License instead of this License.
585
+diff --git a/README.pod b/README.pod
586
+new file mode 100644
587
+index 0000000..d18a96c
588
+--- /dev/null
589
++++ b/README.pod
590
+@@ -0,0 +1,67 @@
591
++=pod
592
++
593
++=head1 NAME
594
++
595
++git-feed - generate an Atom feed of git commits in the current repository
596
++
597
++=head1 SYNOPSIS
598
++
599
++git-feed [ B&#38;lt;--project_url=...&#38;gt; ]
600
++
601
++=head1 DESCRIPTION
602
++
603
++B&#38;lt;--project_url=...&#38;gt;
604
++
605
++=over
606
++
607
++Set a URL for the project.
608
++
609
++=back
610
++
611
++B&#38;lt;--feed_url=...&#38;gt;
612
++
613
++=over
614
++
615
++Set an explicit URL for the feed itself.
616
++
617
++=back
618
++
619
++B&#38;lt;--title=...&#38;gt;
620
++
621
++=over
622
++
623
++Set an explicit title for the feed.  Will otherwise be read from
624
++.git/description, if available.
625
++
626
++=back
627
++
628
++B&#38;lt;--entries=&#38;gt;I&#38;lt;n&#38;gt;
629
++
630
++=over
631
++
632
++Explicitly request I&#38;lt;n&#38;gt; entries.  Defaults to 10.
633
++
634
++=back
635
++
636
++B&#38;lt;--author=...&#38;gt;
637
++
638
++=over
639
++
640
++Explicitly set an author string.  Defaults to git config&#38;#39;s current idea of
641
++user.name.
642
++
643
++=back
644
++
645
++=head1 EXAMPLES
646
++
647
++    git feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
648
++
649
++=head1 AUTHOR
650
++
651
++Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
652
++
653
++=head1 LICENSE
654
++
655
++This utility is free software, licensed under the terms of the GPL, v2.
656
++See COPYING for a complete copy of the license.
657
++
658
+diff --git a/git-feed b/git-feed
659
+new file mode 100755
660
+index 0000000..2c0299e
661
+--- /dev/null
662
++++ b/git-feed
663
+@@ -0,0 +1,179 @@
664
++#!/usr/bin/env perl
665
++
666
++=pod
667
++
668
++=head1 NAME
669
++
670
++git-feed - generate an Atom feed of git commits in the current repository
671
++
672
++=head1 SYNOPSIS
673
++
674
++git-feed [ B&#38;lt;--project_url=...&#38;gt; ]
675
++
676
++=head1 DESCRIPTION
677
++
678
++B&#38;lt;--project_url=...&#38;gt;
679
++
680
++=over
681
++
682
++Set a URL for the project.
683
++
684
++=back
685
++
686
++B&#38;lt;--feed_url=...&#38;gt;
687
++
688
++=over
689
++
690
++Set an explicit URL for the feed itself.
691
++
692
++=back
693
++
694
++B&#38;lt;--title=...&#38;gt;
695
++
696
++=over
697
++
698
++Set an explicit title for the feed.  Will otherwise be read from
699
++.git/description, if available.
700
++
701
++=back
702
++
703
++B&#38;lt;--entries=&#38;gt;I&#38;lt;n&#38;gt;
704
++
705
++=over
706
++
707
++Explicitly request I&#38;lt;n&#38;gt; entries.  Defaults to 10.
708
++
709
++=back
710
++
711
++B&#38;lt;--author=...&#38;gt;
712
++
713
++=over
714
++
715
++Explicitly set an author string.  Defaults to git config&#38;#39;s current idea of
716
++user.name.
717
++
718
++=back
719
++
720
++=head1 EXAMPLES
721
++
722
++    git feed --project_url=https://p1k3.com/userland-book/ &#38;gt; feed.xml
723
++
724
++=head1 AUTHOR
725
++
726
++Brennen Bearnes &#38;lt;bbearnes@gmail.com&#38;gt;
727
++
728
++=head1 LICENSE
729
++
730
++This utility is free software, licensed under the terms of the GPL, v2.
731
++See COPYING for a complete copy of the license.
732
++
733
++=cut
734
++
735
++use warnings;
736
++use strict;
737
++use 5.10.0;
738
++use XML::Atom::SimpleFeed;
739
++use HTML::Entities;
740
++use Getopt::Long;
741
++use POSIX qw(strftime);
742
++use IPC::System::Simple qw(capturex);
743
++
744
++# Figure out where top-level .git resides:
745
++my $repo_base = git(&#38;#39;rev-parse&#38;#39;, &#38;#39;--show-toplevel&#38;#39;);
746
++chomp($repo_base);
747
++
748
++my $title = &#38;#39;git log&#38;#39;;
749
++$title = slurp(&#38;quot;$repo_base/.git/description&#38;quot;)
750
++  if (-f &#38;quot;$repo_base/.git/description&#38;quot;);
751
++
752
++my $author = git_config(&#38;#39;user.name&#38;#39;);
753
++chomp($author);
754
++
755
++my $feed_link = git_config(&#38;#39;feed.link&#38;#39;);
756
++my $project_link = git_config(&#38;#39;feed.projectlink&#38;#39;);
757
++my $entries = 10;
758
++
759
++GetOptions(
760
++  &#38;quot;author:s&#38;quot;       =&#38;gt; \$author,
761
++  &#38;quot;entries:i&#38;quot;      =&#38;gt; \$entries,
762
++  &#38;quot;feed_link:s&#38;quot;    =&#38;gt; \$feed_link,
763
++  &#38;quot;project_link:s&#38;quot; =&#38;gt; \$project_link,
764
++  &#38;quot;title:s&#38;quot;        =&#38;gt; \$title,
765
++);
766
++
767
++# Where does this project live on the web?
768
++unless ($project_link) {
769
++  say &#38;quot;Project link required - use one of:&#38;quot;;
770
++  say &#38;quot;\tgit feed --project_link=https://yourlinkhere/&#38;quot;;
771
++  say &#38;quot;\tgit config feed.projectlink https://yourlinkhere/&#38;quot;;
772
++  exit(1);
773
++}
774
++
775
++# No feed link set?  Make something up.
776
++unless ($feed_link) {
777
++  $feed_link = $project_link . &#38;#39;feed.xml&#38;#39;;
778
++}
779
++
780
++my $log = capturex(&#38;#39;git&#38;#39;, &#38;#39;log&#38;#39;, &#38;quot;-$entries&#38;quot;, qq{--pretty=format:%H _ %ai _ %s});
781
++
782
++my $feed = XML::Atom::SimpleFeed-&#38;gt;new(
783
++  title     =&#38;gt; $title,
784
++  link      =&#38;gt; $project_link,
785
++  link      =&#38;gt; { rel =&#38;gt; &#38;#39;self&#38;#39;, href =&#38;gt; $feed_link, },
786
++  author    =&#38;gt; $author,
787
++  id        =&#38;gt; $project_link,
788
++  generator =&#38;gt; &#38;#39;XML::Atom::SimpleFeed&#38;#39;,
789
++
790
++  # this could be better - just uses current time, at the moment:
791
++  updated   =&#38;gt; iso_date(time()),
792
++);
793
++
794
++while ($log =~ m/^([a-z0-9]+) _ (.*) _ (.*)$/gm) {
795
++  my $hash = $1;
796
++  my $full_commit = git(&#38;#39;show&#38;#39;, $hash);
797
++  my $formatted_commit = &#38;#39;&#38;lt;pre&#38;gt;&#38;#39; . encode_entities($full_commit) . &#38;#39;&#38;lt;/pre&#38;gt;&#38;#39;;
798
++  my $date = $2;
799
++  my $subj = $3;
800
++
801
++  $feed-&#38;gt;add_entry(
802
++    title     =&#38;gt; $subj,
803
++    link      =&#38;gt; $project_link,
804
++    id        =&#38;gt; $hash,
805
++    content   =&#38;gt; $formatted_commit,
806
++    updated   =&#38;gt; $date,
807
++  );
808
++}
809
++
810
++print $feed-&#38;gt;as_string;
811
++
812
++sub iso_date {
813
++  my ($time) = @_;
814
++  return strftime(&#38;quot;%Y-%m-%dT%H:%M:%SZ&#38;quot;, localtime($time));
815
++}
816
++
817
++# get the contents of a file
818
++sub slurp {
819
++  my ($file) = @_;
820
++  my $everything;
821
++
822
++  open my $fh, &#38;#39;&#38;lt;&#38;#39;, $file
823
++    or die &#38;quot;Couldn&#38;#39;t open $file: $!\n&#38;quot;;
824
++
825
++  # line separator:
826
++  local $/ = undef;
827
++  $everything = &#38;lt;$fh&#38;gt;;
828
++
829
++  close $fh
830
++    or die &#38;quot;Couldn&#38;#39;t close: $!&#38;quot;;
831
++
832
++  return $everything;
833
++}
834
++
835
++# run git with some options, return result
836
++sub git { capturex(&#38;#39;git&#38;#39;, @_); }
837
++
838
++sub git_config {
839
++  my ($key) = @_;
840
++  my $value = capturex([0,1], &#38;#39;git&#38;#39;, &#38;#39;config&#38;#39;, &#38;#39;--get&#38;#39;, $key);
841
++  chomp($value);
842
++}
843
+&lt;/pre&gt;</content><updated>2014-10-28 04:51:03 -0600</updated></entry></feed>

Loading…
Cancel
Save