Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started SVN backend

  • Loading branch information...
commit 224dbea83804f014d0d01a14a90be1733613f68c 1 parent 1405266
@piranna authored
Showing with 46 additions and 113 deletions.
  1. +0 −113 git/masterbranch.sh
  2. +46 −0 svn/log2json.pl
View
113 git/masterbranch.sh
@@ -1,113 +0,0 @@
-#!/bin/sh
-VERSION='0.1'
-LISTENERURL='http://localhooks.masterbranch.com/local-hook'
-
-get_last_revision_pushed_to_mb (){
- revision=`git config --local --get masterbranch.lastrevision`
-}
-
-get_user_name () {
- git_name=`git config --global --get user.name`
- if [ -z "$git_name" ]
- then
- git_name=`id | perl -ne 'm/uid=\d+\((\w+)\).*/; print "$1\n" '`
- fi
-}
-
-test_connection(){
- ping -c 2 google.com > /dev/null
- if [ 0 != $? ]
- then
- exit 42
- fi
-}
-
-print_error () {
- printf Please config your client as follows
- printf git config --global --add masterbranch.token TOKEN
- printf git config --global --add masterbranch.email EMAIL
- exit 255
-}
-
-get_token () {
- masterbranch_token=`git config --global --get masterbranch.token`
- if [ -z $masterbranch_token ]
- then
- print_error
- fi
-}
-
-get_email () {
- masterbranch_email=`git config --global --get masterbranch.email`
- if [ -z $masterbranch_email ]
- then
- print_error
- fi
-}
-
-get_repository () {
- uri=`git config --local --get remote.origin.url`
- if [ -z $uri ]
- then
- uri=${PWD##*/}
- fi
-}
-
-do_log () {
- get_user_name
- # Notice than the commit parser just parses this format
- log_output=`git log --author="$git_name" --pretty=format:'COMMITLINEMARK%n{ "revision": "%H", "author": "%an <%ae>", "timestamp": "%ct", "message": "%s%b"}' --raw $last_revision..HEAD`
- raw_data=`$MASTERBRANCH_HOME/git/log2json.pl "$log_output" | tr -d "\n"`
-}
-
-set_last_revision () {
- get_last_revision_pushed_to_mb
- last_revision=$revision
- if [ -z $last_revision ]
- then
- last_revision=`git log -n2 --format=%H | tr "\n" ":" | perl -ne '@revs=split(/:/, $_); print @revs[1]'`
- fi
-}
-
-test_connection
-
-get_token
-token=$masterbranch_token
-get_email
-email=$masterbranch_email
-get_repository
-repository_url=$uri
-
-set_last_revision
-do_log
-
-
-if [ -z "$raw_data" ]
-then
- exit 0
-fi
-
-
-#purge backslashes from the content, that may cause unexpected character escaping in the Json parser. Unexpected double quotes are managed by masterbranch parser
-
-
-#Regular Base64 uses + and / for code point 62 and 63. URL-Safe Base64 uses - and _ instead. Also, URL-Safe base64 omits the == padding to help preserve space.
-#http://en.wikipedia.org/wiki/Base64#URL_applications
-
-encoded_data=`echo "$raw_data" | openssl enc -base64 | tr -d "\n" | tr "+" "-" | tr "/" "_" |tr -d "="`
-
-url_params="email=$email&vcs=git&repository=${repository_url}&token=${token}&payload=${encoded_data}&version=${VERSION}"
-
-curl -d $url_params ${LISTENERURL} > /dev/null 2>&1
-#keeping track of revisions already pushed to masterbranch.com
-if [ $? -eq "0" ]
-then
- actual=`git log -n 1 --format=%H`
- get_last_revision_pushed_to_mb
- if [ -n "$revision" ]
- then
- git config --local --unset-all masterbranch.lastrevision
- fi
- git config --local --add masterbranch.lastrevision $actual
-fi
-
View
46 svn/log2json.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+use strict;
+
+
+my $commit_list="[";
+my @raw_commits=split(/COMMITLINEMARK/,$ARGV[0]);
+
+sub clean_characters{
+ my $commits = shift;
+ $commits =~ s/\\//g;
+ return $commits;
+
+}
+
+foreach my $raw_commit (@raw_commits){
+ my $added;
+ my $deleted;
+ my $modified;
+ my $other;
+
+ if ($raw_commit =~ m/(\{[\S\s]+\})([\S\s]+)/){
+ my $info_section = $1;
+ my $file_section = $2;
+ while ($file_section =~ m/([ACDMRTUXB\*])\s+(\S+)/g){
+ if ($1 eq "A"){
+ $added = $added."\"".$2."\",";
+ } elsif ( $1 eq "D"){
+ $deleted = $deleted."\"".$2."\",";
+ } elsif ( $1 eq "M"){
+ $modified = $modified."\"".$2."\",";
+ } else {
+ $other = $other."\"".$2."\",";
+ }
+ }
+ chop $added;
+ chop $deleted;
+ chop $modified;
+ chop $other;
+ chop $info_section;
+ $info_section= $info_section." , \"added\":[".$added."], \"modified\":[".$modified."], \"deleted\":[".$deleted."], \"other\":[".$other."]}";
+ $commit_list=$commit_list.$info_section.",";
+ }
+}
+chop $commit_list;
+$commit_list = $commit_list."]";
+print clean_characters($commit_list);
Please sign in to comment.
Something went wrong with that request. Please try again.