From a0d3be16897ade364d1039fb2c2169ca4f109b58 Mon Sep 17 00:00:00 2001 From: Tarmigan Casebolt Date: Tue, 19 Jul 2011 16:58:18 +1000 Subject: [PATCH] goinstall, dashboard: Google Code now supports git R=golang-dev, adg, rsc, tarmigan+golang CC=golang-dev https://golang.org/cl/4760055 --- misc/dashboard/godashboard/package.py | 23 ++++++++++++++--------- src/cmd/goinstall/doc.go | 5 ++++- src/cmd/goinstall/download.go | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/misc/dashboard/godashboard/package.py b/misc/dashboard/godashboard/package.py index 87da51424ac..5cc2d2404a6 100644 --- a/misc/dashboard/godashboard/package.py +++ b/misc/dashboard/godashboard/package.py @@ -114,7 +114,7 @@ class Project(db.Model): re_bitbucket = re.compile(r'^(bitbucket\.org/[a-z0-9A-Z_.\-]+/[a-zA-Z0-9_.\-]+)(/[a-z0-9A-Z_.\-/]+)?$') -re_googlecode = re.compile(r'^[a-z0-9\-]+\.googlecode\.com/(svn|hg)(/[a-z0-9A-Z_.\-/]+)?$') +re_googlecode = re.compile(r'^[a-z0-9\-]+\.googlecode\.com/(svn|hg|git)(/[a-z0-9A-Z_.\-/]+)?$') re_github = re.compile(r'^github\.com/[a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)+$') re_launchpad = re.compile(r'^launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?$') @@ -130,7 +130,7 @@ def vc_to_web(path): elif re_googlecode.match(path): m = re_googlecode.match(path) check_url = 'http://'+path - if not m.group(2): # append / after bare '/hg' + if not m.group(2): # append / after bare '/hg' or '/git' check_url += '/' web = 'http://code.google.com/p/' + path[:path.index('.')] elif re_launchpad.match(path): @@ -145,6 +145,17 @@ re_github_web = re.compile(r'github\.com/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)') re_launchpad_web = re.compile(r'launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?') re_striphttp = re.compile(r'https?://(www\.)?') +def find_googlecode_vcs(path): + # Perform http request to path/hg or path/git to check if they're + # using mercurial or git. Otherwise, assume svn. + for vcs in ['git', 'hg']: + try: + response = urlfetch.fetch('http://'+path+vcs, deadline=1) + if response.status_code == 200: + return vcs + except: pass + return 'svn' + def web_to_vc(url): url = re_striphttp.sub('', url) m = re_bitbucket_web.match(url) @@ -156,13 +167,7 @@ def web_to_vc(url): m = re_googlecode_web.match(url) if m: path = m.group(1)+'.googlecode.com/' - # perform http request to path/hg to check if they're using mercurial - vcs = 'svn' - try: - response = urlfetch.fetch('http://'+path+'hg', deadline=1) - if response.status_code == 200: - vcs = 'hg' - except: pass + vcs = find_googlecode_vcs(path) return path + vcs m = re_launchpad_web.match(url) if m: diff --git a/src/cmd/goinstall/doc.go b/src/cmd/goinstall/doc.go index a5df7b3bd4a..53e6f8783a3 100644 --- a/src/cmd/goinstall/doc.go +++ b/src/cmd/goinstall/doc.go @@ -69,7 +69,10 @@ Goinstall recognizes packages from a few common code hosting sites: import "github.com/user/project" import "github.com/user/project/sub/directory" - Google Code Project Hosting (Mercurial, Subversion) + Google Code Project Hosting (Git, Mercurial, Subversion) + + import "project.googlecode.com/git" + import "project.googlecode.com/git/sub/directory" import "project.googlecode.com/hg" import "project.googlecode.com/hg/sub/directory" diff --git a/src/cmd/goinstall/download.go b/src/cmd/goinstall/download.go index da892a69d47..4fdf4167157 100644 --- a/src/cmd/goinstall/download.go +++ b/src/cmd/goinstall/download.go @@ -97,6 +97,7 @@ var git = vcs{ protocols: []string{"git", "https", "http"}, suffix: ".git", defaultHosts: []host{ + {regexp.MustCompile(`^([a-z0-9\-]+\.googlecode\.com/git)(/[a-z0-9A-Z_.\-/]*)?$`), "https", ""}, {regexp.MustCompile(`^(github\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]*)?$`), "http", ".git"}, }, }