- added sandbox support

Thu, 30 Oct 2014 02:02:24 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Thu, 30 Oct 2014 02:02:24 +0200
changeset 47
103f184951bb
parent 46
c4d231fdf1c0
child 48
dbef418cc1c8

- added sandbox support

cobalt.py file | annotate | diff | comparison | revisions
--- a/cobalt.py	Sun Oct 12 16:33:44 2014 +0300
+++ b/cobalt.py	Thu Oct 30 02:02:24 2014 +0200
@@ -229,8 +229,9 @@
 
 check_repo_exists ('zandronum')
 check_repo_exists ('zandronum-stable')
+check_repo_exists ('zandronum-sandbox')
 
-repocheck_timeout = {'zandronum':(time.time()) + 15, 'zandronum-stable':(time.time() + 15)}
+repocheck_timeout = {'zandronum':(time.time()) + 15, 'zandronum-stable':(time.time() + 15), 'zandronum-sandbox':(time.time()) + 15}
 
 def get_commit_data (zanrepo, rev, template):
 	return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template)
@@ -281,7 +282,9 @@
 	global g_clients
 
 	usestable = repo_name == 'zandronum-stable'
-	repo_url = 'https://bitbucket.org/Torr_Samaho/' + repo_name
+	usesandbox = repo_name == 'zandronum-sandbox'
+	repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk'
+	repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
 	num_commits = 0
 
 	if time.time() < repocheck_timeout[repo_name]:
@@ -344,6 +347,13 @@
 				pull_args.insert (1, '../zandronum-stable')
 				devrepo.hg_command (*pull_args)
 			#fi
+
+			# Pull everything into sandbox too
+			if not usesandbox:
+				devrepo = hgapi.Repo ('zandronum-sandbox')
+				pull_args.insert (1, '../%s' % repo_name)
+				devrepo.hg_command (*pull_args)
+			#fi
 		except Exception as e:
 			chanlog ('Warning: unable to pull: %s' % `e`)
 			return
@@ -355,6 +365,34 @@
 		commit_message = commit[1]
 
 		try:
+			if usesandbox:
+				commit_author = get_commit_data (zanrepo, commit_node, '{author}')
+				commit_url = '%s/commits/%s' % (repo_url, commit_node)
+
+				# Remove the email address from the author if possible
+				rex = re.compile (r'^(.+) <([^>]+)>$.*')
+				match = rex.match (commit_author)
+				if match:
+					commit_author = match.group (1)
+				#fi
+
+				for irc_client in g_clients:
+					for channel in irc_client.cfg['channels']:
+						if 'btprivate' in channel and channel['btprivate'] == True:
+							irc_client.privmsg (channel['name'],
+								"%s: new commit %s by %s: %s"
+								% (repo_name, commit_node, commit_author, commit_url))
+
+							for line in commit_message.split ('\n'):
+								irc_client.privmsg (channel['name'], line)
+						#fi
+					#done
+				#done
+
+				num_commits += 1
+				continue
+			#fi
+
 			rex = re.compile (r'^.*(fixes|resolves|addresses) ([0-9]+).*$')
 			match = rex.match (commit_message)
 
@@ -612,7 +650,7 @@
 			bt_checklatest()
 
 			# Check for new commits in the repositories
-			for n in ['zandronum-stable', 'zandronum']:
+			for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox']:
 				process_zan_repo_updates (n)
 
 	def channel_by_name (self, name):
@@ -924,9 +962,9 @@
 		elif command == 'checkhg':
 			check_admin (sender, ident, host, command)
 			global repocheck_timeout
-			repocheck_timeout = {'zandronum':0, 'zandronum-stable':0}
+			repocheck_timeout = {'zandronum':0, 'zandronum-stable':0, 'zandronum-sandbox':0}
 
-			for n in ['zandronum-stable', 'zandronum']:
+			for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox']:
 				numcommits = process_zan_repo_updates (n)
 
 				if numcommits == 0:

mercurial