Skip to content
shak-mar edited this page Aug 28, 2014 · 3 revisions

Signal

An implementation of the observer pattern. You can create your own signal with:

import push_analyzer.utils
my_signal = push_analyzer.utils.Signal ()

now you can subscribe functions:

def greet ( name ):
  print ( 'Hi there, ' + name )
names.subscribe ( greet )

or unsubscribe:

names.unsubscribe ( say_goodbye )

Whenever you call a signal, it will call all the subscribers and forward the arguments:

names ( 'Peter' ) # -> 'Hi there, Peter'
names ( 'Sarah' ) # -> 'Hi there, Sarah'

refs dict

A dict mapping ref names to the hashes they are pointing at. You can build one with:

import push_analyzer.utils
refs_dict = push_analyzer.utils.build_ref_dict ()
print ( refs_dict )
# formatted example output:
{
    b'origin/master': b'08148ce355da90a0cc31e540a6f8462cfa0de3a8',
    b'origin/HEAD': b'08148ce355da90a0cc31e540a6f8462cfa0de3a8',
    b'origin/cleanup': b'9c93920e777137bbf6b105e203eaf88fb62910b3',
    b'master': b'08148ce355da90a0cc31e540a6f8462cfa0de3a8'
}

or get the latest refs dict with:

import push_analyzer.poll
refs_dict = push_analyzer.poll.latest_refs ()

changes dict

The analyzer calls the analyzer.results Signal with a changes dict. Every changes dict contains a type field, that contains the type of the change.

Depending on the type of the change, it also contains these fields:

  • create branch, remove branch
    • name : name of the branch
  • update, forced update
    • name : name of the ref updated
    • changes : list of change types contained in the update also contains same overall diff, if the update only cleaned up the history, but didn't change the overall diff.
    • from : sha the ref pointed to previously
    • to : sha the ref points to after the change
  • add, remove
    • sha : hash of the commit
  • move A change has this type if the diff of a commit stays the same, but it has a different sha.
    • from : hash of the previous commit
    • to : hash of the rewritten commit
Clone this wiki locally