A script to generate Atom feeds for git commit logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

842 lines
34 KiB

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