Skip to content

Commit b6ecc9c

Browse files
committed
New option to skip updates that a remote already knows.
``--ignoreremotes`` If given, ``git-notifier`` will not report any commits that are already known by any configured remote repository. In addition, github-notifier now also updates all remotes when it runs.
1 parent 043ade2 commit b6ecc9c

File tree

6 files changed

+37
-19
lines changed

6 files changed

+37
-19
lines changed

.update-changes.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ function new_version_hook
55
version=$1
66
replace_version_in_script git-notifier $version
77
replace_version_in_script github-notifier $version
8-
replace_version_in_rst README $version
8+
replace_version_in_rst README.rst $version
99
}

CHANGES

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11

2+
0.5 | 2014-01-27 07:42:48 -0800
3+
4+
* New option to skip updates that a remote already knows.
5+
6+
``--ignoreremotes``
7+
If given, ``git-notifier`` will not report any commits tha
8+
are already known by any configured remote repository.
9+
10+
In addition, github-notifier now also updates all remotes when it runs. (Robin Sommer)
11+
12+
* README updates. (Robin Sommer)
13+
214
0.42-4 | 2013-09-25 22:15:07 -0700
315

416
* Updating README for github-notifier. (Robin Sommer)

README.rst

+11-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.. |date| date::
44

55
.. Version number is filled in automatically.
6-
.. |version| replace:: 0.42-4
6+
.. |version| replace:: 0.5
77

88
git-notifier
99
============
@@ -89,8 +89,8 @@ mail will be send for that change.
8989
Download
9090
--------
9191

92-
The current release is `git-notifier 0.42
93-
<http://www.icir.org/robin/git-notifier/git-notifier-0.42.tar.gz>`_
92+
The current release is `git-notifier 0.5
93+
<http://www.icir.org/robin/git-notifier/git-notifier-0.5.tar.gz>`_
9494

9595
Not surprisingly, ``git-notifier`` is maintained in a git repository
9696
that you clone::
@@ -131,7 +131,6 @@ giving them on the command line, all of them can alse be set via
131131
address, do ``git config hooks.mailinglist [email protected]``:
132132

133133
``--allchanges <branches>``
134-
135134
Lists branches for which *all* changes made to them should be
136135
mailed out as straight diffs to their previous state,
137136
independent of whether the corresponding commit has already
@@ -177,6 +176,10 @@ address, do ``git config hooks.mailinglist [email protected]``:
177176
path shown in the notification mails. Default is the
178177
canonical name of the system the script is running on.
179178

179+
``--ignoreremotes``
180+
If given, ``git-notifier`` will not report any commits that
181+
are already known by any configured remote repository.
182+
180183
``--link <url>``
181184
Specifies a URL that will be included into notification mails
182185
for locating a changeset online. The URL can contain a "%s"
@@ -268,10 +271,6 @@ address, do ``git config hooks.mailinglist [email protected]``:
268271
Monitoring GitHub
269272
-----------------
270273

271-
.. note::
272-
273-
This is still experimental.
274-
275274
The ``git-notifier`` distribution comes with a companion script,
276275
``github-notifier``, that watches GitHub repositories for changes. The
277276
script maintains a local mirror of repositories you want to watch and
@@ -300,13 +299,10 @@ subsequent executions, the script will update the clone and spawn
300299
``git-notifier`` to email out notifications. For now, the best way to
301300
automate this is to run ``github-notifier`` from ``cron``.
302301

303-
.. note::
304-
305-
In the future we might add a daemon mode to ``github-notifier``
306-
that keeps it running in the background, polling for updates
307-
regularly. Potentially it could even be triggered by a `GitHub web
308-
hook <https://help.github.com/articles/post-receive-hooks>`_
309-
302+
Note: In the future we might add a daemon mode to ``github-notifier``
303+
that keeps it running in the background, polling for updates
304+
regularly. Potentially it could even be triggered by a `GitHub web
305+
hook <https://help.github.com/articles/post-receive-hooks>`_
310306

311307
In the following we discuss more details of the configuration file.
312308

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.42-4
1+
0.5

git-notifier

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import sys
1010
import tempfile
1111
import time
1212

13-
VERSION = "0.42-4" # Filled in automatically.
13+
VERSION = "0.5" # Filled in automatically.
1414

1515
Name = "git-notifier"
1616
CacheFile = ".%s.dat" % Name
@@ -47,6 +47,7 @@ Options = [
4747
("users", True, None, "location of a user-to-email mapping file"),
4848
("replyto", True, None, "email address for reply-to header"),
4949
("mergediffs", True, set(), "branches for which complete merge diffs are to be included"),
50+
("ignoreremotes", False, False, "don't report commits that a remote already knows"),
5051
]
5152

5253
class State:
@@ -430,6 +431,14 @@ def commit(current, rev, force=False, subject_head=None):
430431
log("Flagged revision %s for notification, but already reported this time" % rev)
431432
return
432433

434+
if Config.ignoreremotes:
435+
branches = [line.split()[-1] for line in git("branch -a --contains=%s" % rev)]
436+
437+
for b in branches:
438+
if b.startswith("remotes/"):
439+
log("Flagged revision %s for notification, but already known by remote" % rev)
440+
return
441+
433442
log("New revision %s" % rev)
434443
current.reported.add(rev)
435444

github-notifier

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import subprocess
1111
import sys
1212
import github
1313

14-
VERSION = "0.42-4" # Filled in automatically.
14+
VERSION = "0.5" # Filled in automatically.
1515

1616
Name = "github-notifier"
1717
ConfigFile = "./%s.cfg" % Name
@@ -81,6 +81,7 @@ def gitUpdate(repo):
8181
runCommand("git --bare init --quiet")
8282
runCommand("git --bare fetch --quiet %s +refs/heads/*:refs/heads/*" % repo.url(True))
8383
runCommand("git --bare fetch --quiet %s +refs/tags/*:refs/tags/*" % repo.url(True))
84+
runCommand("git remote update >/dev/null")
8485
popDirectory()
8586

8687
def runNotifier(repo):

0 commit comments

Comments
 (0)