List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] contrib/hooks: add sample post-receive hook using agefile
@ 2014-12-23 14:40 john
  2014-12-23 15:15 ` mailings
  2015-08-12 12:06 ` Jason
  0 siblings, 2 replies; 9+ messages in thread
From: john @ 2014-12-23 14:40 UTC (permalink / raw)


One of the most frequent questions on the mailing list relates to the
idle time in the repository list.  The answer to this is to use the
"agefile" feature to calculate the time of the last change whenever the
repository receives changes.

Add a sample post-receive hook in a new "contrib" directory so that we
can just point people at the repository in the future.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 contrib/hooks/post-receive.agefile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 contrib/hooks/post-receive.agefile

diff --git a/contrib/hooks/post-receive.agefile b/contrib/hooks/post-receive.agefile
new file mode 100755
index 0000000..2f72ae9
--- /dev/null
+++ b/contrib/hooks/post-receive.agefile
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# An example hook to update the "agefile" for CGit's idle time calculation.
+#
+# This hook assumes that you are using the default agefile location of
+# "info/web/last-modified".  If you change the value in your cgitrc then you
+# must also change it here.
+#
+# To install the hook, copy (or link) it to the file "hooks/post-receive" in
+# each of your repositories.
+#
+
+agefile="$(git rev-parse --git-dir)"/info/web/last-modified
+
+mkdir -p "$(dirname "$agefile")" &&
+git for-each-ref \
+	--sort=-authordate --count=1 \
+	--format='%(authordate:iso8601)' \
+	>"$agefile"
-- 
2.2.1.286.gdf3164c



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2014-12-23 14:40 [PATCH] contrib/hooks: add sample post-receive hook using agefile john
@ 2014-12-23 15:15 ` mailings
  2014-12-23 15:48   ` john
  2015-08-12 12:06 ` Jason
  1 sibling, 1 reply; 9+ messages in thread
From: mailings @ 2014-12-23 15:15 UTC (permalink / raw)




On 23/12/14 15:40, John Keeping wrote:
> +agefile="$(git rev-parse --git-dir)"/info/web/last-modified

use $GIT_DIR here instead of rev-parse

> +
> +mkdir -p "$(dirname "$agefile")" &&
> +git for-each-ref \
> +	--sort=-authordate --count=1 \
> +	--format='%(authordate:iso8601)' \
> +	>"$agefile"

-- 
Ferry Huberts


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2014-12-23 15:15 ` mailings
@ 2014-12-23 15:48   ` john
  2014-12-23 16:12     ` mailings
  0 siblings, 1 reply; 9+ messages in thread
From: john @ 2014-12-23 15:48 UTC (permalink / raw)


On Tue, Dec 23, 2014 at 04:15:15PM +0100, Ferry Huberts wrote:
> 
> 
> On 23/12/14 15:40, John Keeping wrote:
> > +agefile="$(git rev-parse --git-dir)"/info/web/last-modified
> 
> use $GIT_DIR here instead of rev-parse

githooks(5) doesn't guarantee that GIT_DIR will be set and the fact that
it currently is seems to be an artifact of how old versions of Git work
([0]).

I'd prefer to stick with rev-parse, which is what the example hooks in
git.git use.

[0] http://permalink.gmane.org/gmane.comp.version-control.git/136276

> > +
> > +mkdir -p "$(dirname "$agefile")" &&
> > +git for-each-ref \
> > +	--sort=-authordate --count=1 \
> > +	--format='%(authordate:iso8601)' \
> > +	>"$agefile"


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2014-12-23 15:48   ` john
@ 2014-12-23 16:12     ` mailings
  2015-08-12 10:54       ` john
  0 siblings, 1 reply; 9+ messages in thread
From: mailings @ 2014-12-23 16:12 UTC (permalink / raw)




On 23/12/14 16:48, John Keeping wrote:
> On Tue, Dec 23, 2014 at 04:15:15PM +0100, Ferry Huberts wrote:
>>
>>
>> On 23/12/14 15:40, John Keeping wrote:
>>> +agefile="$(git rev-parse --git-dir)"/info/web/last-modified
>>
>> use $GIT_DIR here instead of rev-parse
>
> githooks(5) doesn't guarantee that GIT_DIR will be set and the fact that
> it currently is seems to be an artifact of how old versions of Git work
> ([0]).
>
> I'd prefer to stick with rev-parse, which is what the example hooks in
> git.git use.
>
> [0] http://permalink.gmane.org/gmane.comp.version-control.git/136276
>

Ok with me.
I did check the man pages and they seem to say that GITDIR is set.
Well, whatever :-)

>>> +
>>> +mkdir -p "$(dirname "$agefile")" &&
>>> +git for-each-ref \
>>> +	--sort=-authordate --count=1 \
>>> +	--format='%(authordate:iso8601)' \
>>> +	>"$agefile"

-- 
Ferry Huberts


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2014-12-23 16:12     ` mailings
@ 2015-08-12 10:54       ` john
  2015-08-12 12:05         ` Jason
  0 siblings, 1 reply; 9+ messages in thread
From: john @ 2015-08-12 10:54 UTC (permalink / raw)


Jason, did you decide not to apply this or was it just lost in the
noise?

[Thread starts here:
http://article.gmane.org/gmane.comp.version-control.cgit/2258
]

On Tue, Dec 23, 2014 at 05:12:41PM +0100, Ferry Huberts wrote:
> On 23/12/14 16:48, John Keeping wrote:
> > On Tue, Dec 23, 2014 at 04:15:15PM +0100, Ferry Huberts wrote:
> >>
> >>
> >> On 23/12/14 15:40, John Keeping wrote:
> >>> +agefile="$(git rev-parse --git-dir)"/info/web/last-modified
> >>
> >> use $GIT_DIR here instead of rev-parse
> >
> > githooks(5) doesn't guarantee that GIT_DIR will be set and the fact that
> > it currently is seems to be an artifact of how old versions of Git work
> > ([0]).
> >
> > I'd prefer to stick with rev-parse, which is what the example hooks in
> > git.git use.
> >
> > [0] http://permalink.gmane.org/gmane.comp.version-control.git/136276
> >
> 
> Ok with me.
> I did check the man pages and they seem to say that GITDIR is set.
> Well, whatever :-)
> 
> >>> +
> >>> +mkdir -p "$(dirname "$agefile")" &&
> >>> +git for-each-ref \
> >>> +	--sort=-authordate --count=1 \
> >>> +	--format='%(authordate:iso8601)' \
> >>> +	>"$agefile"


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2015-08-12 10:54       ` john
@ 2015-08-12 12:05         ` Jason
  0 siblings, 0 replies; 9+ messages in thread
From: Jason @ 2015-08-12 12:05 UTC (permalink / raw)


Lost in the noise.

I need to allocate some time in the next few weeks to sift through the ML
and apply all the patches and merge a change of my own I've sitting on for
a bit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150812/45c40930/attachment.html>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2014-12-23 14:40 [PATCH] contrib/hooks: add sample post-receive hook using agefile john
  2014-12-23 15:15 ` mailings
@ 2015-08-12 12:06 ` Jason
  2015-08-12 13:41   ` Jason
  1 sibling, 1 reply; 9+ messages in thread
From: Jason @ 2015-08-12 12:06 UTC (permalink / raw)


Merged. I'll review the backlog of the rest of the ML soon enough.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150812/6b4e5d05/attachment.html>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2015-08-12 12:06 ` Jason
@ 2015-08-12 13:41   ` Jason
  2015-08-12 15:04     ` john
  0 siblings, 1 reply; 9+ messages in thread
From: Jason @ 2015-08-12 13:41 UTC (permalink / raw)


You might want to add this to
http://git.zx2c4.com/cgit/about/faq


git checkout wiki
vim faq


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] contrib/hooks: add sample post-receive hook using agefile
  2015-08-12 13:41   ` Jason
@ 2015-08-12 15:04     ` john
  0 siblings, 0 replies; 9+ messages in thread
From: john @ 2015-08-12 15:04 UTC (permalink / raw)


On Wed, Aug 12, 2015 at 03:41:57PM +0200, Jason A. Donenfeld wrote:
> You might want to add this to
> http://git.zx2c4.com/cgit/about/faq

Something like this (which probably needs a bit of editing to make the
tone consistent with what's already there)?

-- >8 --
Subject: [PATCH] faq: add an entry about the agefile

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 faq | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/faq b/faq
index 9c3ff01..e940510 100644
--- a/faq
+++ b/faq
@@ -26,3 +26,16 @@ the .git directory.
 A less likely cause is that the repo is, infact, not a valid repo. Try
 to run 'git show' in the offending repo to see if git also thinks your
 repo has issues.
+
+
+### Why is the idle time for my repository wrong?
+
+By default CGit uses the modification time of the default branch's ref
+file as a quick method of determining when the repository was last
+changed.  If you primarily work on other branches then this work will
+not be reflected in the idle time.
+
+You can use a post-receive hook to run a script that tells CGit the
+correct modification time by writing to ``info/web/last-modified``.  An
+example is provided in the CGit repository at
+``contrib/hooks/post-receive.agefile``.
-- 
2.5.0.466.g9af26fa



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-12 15:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-23 14:40 [PATCH] contrib/hooks: add sample post-receive hook using agefile john
2014-12-23 15:15 ` mailings
2014-12-23 15:48   ` john
2014-12-23 16:12     ` mailings
2015-08-12 10:54       ` john
2015-08-12 12:05         ` Jason
2015-08-12 12:06 ` Jason
2015-08-12 13:41   ` Jason
2015-08-12 15:04     ` john

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).