Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 491808 | Differences between
and this patch

Collapse All | Expand All

(-)a/irkerhook.py (-32 / +3 lines)
Lines 57-63 class Commit: Link Here
57
        self.rev = None
57
        self.rev = None
58
        self.mail = None
58
        self.mail = None
59
        self.author = None
59
        self.author = None
60
        self.files = None
61
        self.logmsg = None
60
        self.logmsg = None
62
        self.url = None
61
        self.url = None
63
        self.author_date = None
62
        self.author_date = None
Lines 223-229 class GitExtractor(GenericExtractor): Link Here
223
        self.channels = do("git config --get irker.channels")
222
        self.channels = do("git config --get irker.channels")
224
        self.email = do("git config --get irker.email")
223
        self.email = do("git config --get irker.email")
225
        self.tcp = do("git config --bool --get irker.tcp")
224
        self.tcp = do("git config --bool --get irker.tcp")
226
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
225
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
227
        self.tinyifier = do("git config --get irker.tinyifier") or default_tinyifier
226
        self.tinyifier = do("git config --get irker.tinyifier") or default_tinyifier
228
        self.color = do("git config --get irker.color")
227
        self.color = do("git config --get irker.color")
229
        self.urlprefix = do("git config --get irker.urlprefix") or "gitweb"
228
        self.urlprefix = do("git config --get irker.urlprefix") or "gitweb"
Lines 268-276 class GitExtractor(GenericExtractor): Link Here
268
            commit.rev = do("git describe %s 2>/dev/null" % shellquote(commit.commit))
267
            commit.rev = do("git describe %s 2>/dev/null" % shellquote(commit.commit))
269
        if not commit.rev:
268
        if not commit.rev:
270
            commit.rev = commit.commit[:12]
269
            commit.rev = commit.commit[:12]
271
        # Extract the meta-information for the commit
272
        commit.files = do("git diff-tree -r --name-only " + shellquote(commit.commit))
273
        commit.files = " ".join(commit.files.strip().split("\n")[1:])
274
        # Design choice: for git we ship only the first line, which is
270
        # Design choice: for git we ship only the first line, which is
275
        # conventionally supposed to be a summary of the commit.  Under
271
        # conventionally supposed to be a summary of the commit.  Under
276
        # other VCSes a different choice may be appropriate.
272
        # other VCSes a different choice may be appropriate.
Lines 294-300 class SvnExtractor(GenericExtractor): Link Here
294
            if tok.startswith("--repository="):
290
            if tok.startswith("--repository="):
295
                self.repository = tok[13:]
291
                self.repository = tok[13:]
296
        self.project = os.path.basename(self.repository)
292
        self.project = os.path.basename(self.repository)
297
        self.template = '%(bold)s%(project)s%(reset)s: %(green)s%(author)s%(reset)s %(repo)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
293
        self.template = '%(bold)s%(project)s%(reset)s: %(green)s%(author)s%(reset)s %(repo)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
298
        self.urlprefix = "viewcvs"
294
        self.urlprefix = "viewcvs"
299
        self.load_preferences(os.path.join(self.repository, "irker.conf"))
295
        self.load_preferences(os.path.join(self.repository, "irker.conf"))
300
        self.do_overrides()
296
        self.do_overrides()
Lines 308-314 class SvnExtractor(GenericExtractor): Link Here
308
        commit.rev = "r%s" % self.id
304
        commit.rev = "r%s" % self.id
309
        commit.author = self.svnlook("author")
305
        commit.author = self.svnlook("author")
310
        commit.commit_date = self.svnlook("date").partition('(')[0]
306
        commit.commit_date = self.svnlook("date").partition('(')[0]
311
        commit.files = self.svnlook("dirs-changed").strip().replace("\n", " ")
312
        commit.logmsg = self.svnlook("log").strip()
307
        commit.logmsg = self.svnlook("log").strip()
313
        return commit
308
        return commit
314
    def svnlook(self, info):
309
    def svnlook(self, info):
Lines 352-358 class HgExtractor(GenericExtractor): Link Here
352
        self.channels = ui.config('irker', 'channels')
347
        self.channels = ui.config('irker', 'channels')
353
        self.email = ui.config('irker', 'email')
348
        self.email = ui.config('irker', 'email')
354
        self.tcp = str(ui.configbool('irker', 'tcp'))  # converted to bool again in do_overrides
349
        self.tcp = str(ui.configbool('irker', 'tcp'))  # converted to bool again in do_overrides
355
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
350
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
356
        self.tinyifier = ui.config('irker', 'tinyifier') or default_tinyifier
351
        self.tinyifier = ui.config('irker', 'tinyifier') or default_tinyifier
357
        self.color = ui.config('irker', 'color')
352
        self.color = ui.config('irker', 'color')
358
        self.urlprefix = (ui.config('irker', 'urlprefix') or
353
        self.urlprefix = (ui.config('irker', 'urlprefix') or
Lines 382-390 class HgExtractor(GenericExtractor): Link Here
382
        commit.author_date = \
377
        commit.author_date = \
383
            datetime.datetime.fromtimestamp(ctx.date()[0]).strftime('%Y-%m-%d %H:%M:%S')
378
            datetime.datetime.fromtimestamp(ctx.date()[0]).strftime('%Y-%m-%d %H:%M:%S')
384
        commit.logmsg = ctx.description()
379
        commit.logmsg = ctx.description()
385
        # Extract changed files from status against first parent
386
        st = self.repository.status(ctx.p1().node(), ctx.node())
387
        commit.files = ' '.join(st[0] + st[1] + st[2])
388
        return commit
380
        return commit
389
381
390
def hg_hook(ui, repo, **kwds):
382
def hg_hook(ui, repo, **kwds):
Lines 425-451 def ship(extractor, commit, debug): Link Here
425
            sys.stderr.write("irkerhook.py: could not decode JSON: %s\n" % data)
417
            sys.stderr.write("irkerhook.py: could not decode JSON: %s\n" % data)
426
            raise SystemExit, 1
418
            raise SystemExit, 1
427
419
428
    # Rewrite the file list if too long. The objective here is only
429
    # to be easier on the eyes.
430
    if extractor.cialike \
431
           and extractor.cialike.lower() != "none" \
432
           and len(metadata.files) > int(extractor.cialike):
433
        files = metadata.files.split()
434
        dirs = set([d.rpartition('/')[0] for d in files])
435
        if len(dirs) == 1:
436
            metadata.files = "(%s files)" % (len(files),)
437
        else:
438
            metadata.files = "(%s files in %s dirs)" % (len(files), len(dirs))
439
    # Message reduction.  The assumption here is that IRC can't handle
440
    # lines more than 510 characters long. If we exceed that length, we
441
    # try knocking out the file list, on the theory that for notification
442
    # purposes the commit text is more important.  If it's still too long
443
    # there's nothing much can be done other than ship it expecting the IRC
444
    # server to truncate.
445
    privmsg = unicode(metadata)
420
    privmsg = unicode(metadata)
446
    if len(privmsg) > 510:
447
        metadata.files = ""
448
        privmsg = unicode(metadata)
449
421
450
    # Anti-spamming guard.  It's deliberate that we get maxchannels not from
422
    # Anti-spamming guard.  It's deliberate that we get maxchannels not from
451
    # the user-filtered metadata but from the extractor data - means repo
423
    # the user-filtered metadata but from the extractor data - means repo
452
- 

Return to bug 491808