GitMonitor


With the explosion of git it seems that keeping track of what is happening across repositories that may span personal, open source and work projects can become a challenge in itself.

Perhaps you’ve subscribed to some sort of bespoke notification system in whatever service is hosting the repositories, maybe it’s an email alert, rss feed or you go to a status page to see activity streams. You probably end up marking notifications as read and forgetting about most of them, then wondering where you saw an update about something…

The aim of GitMonitor is to provide a simple solution to tracking changes across repositories that you are interested in. There are no notifications to deal with, no emails, no distractions. Simply view time based changes whenever you choose to.

main.png

Basic Idea

  • You clone repositories you care about and configure a task to update them per whatever schedule you deem appropriate.
  • You point GitMonitor at your clones and use it to track and view changes.
  • You also get a Rest API so other apps can feed on the data.

Tech

The solution is based on ASP.NET 5, BootStrap for the UI and libgit2sharp for the gitty stuff.

Walkthrough

Build the Code

Download the latest code or release from github @ https://github.com/mikefourie/GitMonitor/releases

You’re going to want to edit the gitmonitorconfig.json file to suit your needs. You’ll understand the file more after completing this walkthrough. For now, let’s replace the downloaded file with the following

{
  "Defaults": {
    "DefaultDays": "-3",
    "DefaultRemote": "origin",
    "DefaultBranch": "master",
    "DefaultUserNameExcludeFilter": "ServiceUser"
  },
  "MonitoredPathConfig": {
    "MonitoredPaths": [
      {
        "Path": "c:\\gitcode",
        "Name": "Default",
        "AllFolders": true
      }
    ]
 }
}

For the walkthrough let’s assume the repo’s you have are or will be in the path specified in the config, if not, edit that path. Open the solution and publish the site to the file system. You should see something like this

publish

Copy all that content to where you want to host the website, for example C:\websites\gitmonitor. Make sure you give IIS_IUSRS permission to read that path

Configure IIS

Make sure you install the HTTP Platform Handler

Create an app pool with No Managed Code for the .NET CLR version.

apppool

Create a website and use that app pool, point it to the wwwroot folder of your content, choose a port you have free

website

Try browse the site, if you see

HTTP Error 500.19 – Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Make sure you have HTTP Activation installed too:

httpactivation

If it works and assuming the path you specified has no repositories yet, you will see the following

start

Clone Repositories

Now we need to clone repositories so we can use GitMonitor to view changes for the specified number of days.I’ll just clone the personal ones I have on github into c:\gitcode and refresh the page…

defaulthistory

Based on the config file the page shows 3 days worth of history, if I click 90, we see any repository with changes in that period show up, e.g. below I see a total of 11 changes in two repositories.

90history

That’s the basics of the solution no lets tweak the config file to improve the experience.

More Please

Chances are that you want to track repositories which you may not contribute to, for example libgit2sharp and ilspy on github. We want to put those somewhere out the way and easily include them in GitMonitor.

First we need to clone the repos. Because we are not going to edit this repos we’ll just create a mirror and tweak what we fetch as we are only interested in master branch(es).

I’ll put them in a folder called C:\gitcode\githubtrack. To create a mirror we simply run

then cd into ilspy and run

  • C:\gitcode\githubtrack\ilspy>git config remote.origin.fetch +refs/*/master:refs/*/master

After cloning the repos you will need to update the config to make GitMonitor aware of the additional monitored path. Update it as follows and then restart the website so the config is refreshed

{
 "Defaults": {
 "DefaultDays": "-3",
 "DefaultRemote": "origin",
 "DefaultBranch": "master",
 "DefaultUserNameExcludeFilter": "ServiceUser"
 },
 "MonitoredPathConfig": {
 "MonitoredPaths": [
 {
 "Path": "c:\\gitcode",
 "Name": "Default",
 "AllFolders": true
 },
 {
 "Path": "c:\\gitcode\\githubtrack",
 "Name": "github track",
 "AllFolders": true,
 "Days": "-10",
 "Repositories": [
 {
 "Name": "ilspy",
 "Remote": "origin",
 "Branch": "master"
 },
 {
 "Name": "libgit2sharp",
 "Remote": "origin",
 "Branch": "master"
 }
 ]
 },
 ]
 }
}

Below I have refreshed the site, clicked the new github track link and selected 14 days

githubtrack

Let’s try adding another monitored path, this time I’ll add all the almrangers repositories so I can easily monitor progress across the alm rangers program.

I can clone all the repos into an almrangers folder but so far you will have noticed that there is no way to get to more information about the commits. Lets tweak the config to light that up…

{
 "Defaults": {
 "DefaultDays": "-3",
 "DefaultRemote": "origin",
 "DefaultBranch": "master",
 "DefaultUserNameExcludeFilter": "ServiceUser"
 },
 "MonitoredPathConfig": {
 "MonitoredPaths": [
 {
 "Path": "c:\\gitcode",
 "Name": "Default",
 "AllowFetch": true,
 "AllFolders": true
 },
 {
 "Path": "c:\\gitcode\\almrangers",
 "Name": "alm rangers",
 "AllFolders": true,
 "AllowFetch": true,
 "Days": "-10",
 "Repositories": [
 {
 "Name": "VSO-Extension-FolderManagement",
 "CommitUrl": "https://github.com/ALM-Rangers/VSO-Extension-FolderManagement/commit/",
 "Remote": "origin",
 "Branch": "master",
 },

 {
 "Name": "Extracting-effective-permissions-from-TFS",
 "CommitUrl": "https://github.com/ALM-Rangers/Extracting-effective-permissions-from-TFS/commit/",
 "Remote": "origin",
 "Branch": "master"
 },
 {
 "Name": "VSTS-Extension-PrintCards",
 "CommitUrl": "https://github.com/ALM-Rangers/VSTS-Extension-PrintCards/commit/",
 "Remote": "origin",
 "Branch": "master"
 },
 {
 "Name": "Migrate-assets-from-RM-server-to-VSTS",
 "CommitUrl": "https://github.com/ALM-Rangers/Migrate-assets-from-RM-server-to-VSTS/commit/",
 "Remote": "origin",
 "Branch": "master"
 },
 {
 "Name": "Template",
 "CommitUrl": "https://github.com/ALM-Rangers/Template/commit/",
 "Remote": "origin",
 "Branch": "master"
 }
 ]
 },
 {
 "Path": "c:\\gitcode\\githubtrack",
 "Name": "github track",
 "AllFolders": true,
 "Days": "-10",
 "Repositories": [
 {
 "Name": "ilspy",
 "CommitUrl": "https://github.com/icsharpcode/ILSpy/commit/",
 "Remote": "origin",
 "Branch": "master"
 },
 {
 "Name": "libgit2sharp",
 "CommitUrl": "https://github.com/libgit2/libgit2sharp/commit/",
 "Remote": "origin",
 "Branch": "master"
 }
 ]
 }
 ]
 }
}

By adding the commiturls we see below that the commits are now links which we can use to go view the details. Also note the new Fetch button which allows a manual Fetch to be executed across all repo’s in the path. This is enabled by adding the AllowFetch property and setting it to true.

rangers.png

Those repository names are pretty long, + because these repo’s don’t rebase, we need to show merge commits. We can add a FriendlyName property to each repository and at the path level we can set IncludeMergeCommits to true to view those…

merge.png

There are a few other options that can be configured. I’ll document those fully on github.

Rest

GitMonitor provides a rest interface too. You may want to provide commit information in other apps and getting the info is fairly straight forward. Using something like Postman to test out the various calls, for example to get the default data out from the first path you configure, simply hit http://<yoururl>/api/commits

postman

Here are a few more samples

Get 90 days worth of commits – /api/commits/90

Get 100 days worth of commits from ilspy – api/commits/github track/ilspy/100

Get 60 days worht of commits from the newdecompiler branch in ilspy – api/commits/github track?repoName=ilspy&branchName=newdecompiler&days=60

Hopefully this solution helps a few folks. I’ll be adding a few more features soon so keep an eye on the project @ https://github.com/mikefourie/GitMonitor and please feel free to log issues and requests.

Mike

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s