1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:57:57 -07:00

goinstall, dashboard: Google Code now supports git

R=golang-dev, adg, rsc, tarmigan+golang
CC=golang-dev
https://golang.org/cl/4760055
This commit is contained in:
Tarmigan Casebolt 2011-07-19 16:58:18 +10:00 committed by Andrew Gerrand
parent 423ab2333a
commit a0d3be1689
3 changed files with 19 additions and 10 deletions

View File

@ -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_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_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_.\-/]+)?$') 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): elif re_googlecode.match(path):
m = re_googlecode.match(path) m = re_googlecode.match(path)
check_url = 'http://'+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 += '/' check_url += '/'
web = 'http://code.google.com/p/' + path[:path.index('.')] web = 'http://code.google.com/p/' + path[:path.index('.')]
elif re_launchpad.match(path): 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_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\.)?') 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): def web_to_vc(url):
url = re_striphttp.sub('', url) url = re_striphttp.sub('', url)
m = re_bitbucket_web.match(url) m = re_bitbucket_web.match(url)
@ -156,13 +167,7 @@ def web_to_vc(url):
m = re_googlecode_web.match(url) m = re_googlecode_web.match(url)
if m: if m:
path = m.group(1)+'.googlecode.com/' path = m.group(1)+'.googlecode.com/'
# perform http request to path/hg to check if they're using mercurial vcs = find_googlecode_vcs(path)
vcs = 'svn'
try:
response = urlfetch.fetch('http://'+path+'hg', deadline=1)
if response.status_code == 200:
vcs = 'hg'
except: pass
return path + vcs return path + vcs
m = re_launchpad_web.match(url) m = re_launchpad_web.match(url)
if m: if m:

View File

@ -69,7 +69,10 @@ Goinstall recognizes packages from a few common code hosting sites:
import "github.com/user/project" import "github.com/user/project"
import "github.com/user/project/sub/directory" 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"
import "project.googlecode.com/hg/sub/directory" import "project.googlecode.com/hg/sub/directory"

View File

@ -97,6 +97,7 @@ var git = vcs{
protocols: []string{"git", "https", "http"}, protocols: []string{"git", "https", "http"},
suffix: ".git", suffix: ".git",
defaultHosts: []host{ 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"}, {regexp.MustCompile(`^(github\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]*)?$`), "http", ".git"},
}, },
} }