Browse Source

nothing

pull/103/head
Unknown 12 years ago
parent
commit
423141e0d6
  1. 0
      conf/sources.txt
  2. 114
      doc/bitbucket.go
  3. 2
      i18n/en-US/usage_install.txt
  4. 5
      install.go

0
conf/sources.txt

114
doc/bitbucket.go

@ -0,0 +1,114 @@
// Copyright 2011 Gary Burd
// Copyright 2013 Unknown
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package doc
import (
"net/http"
"path"
"regexp"
"github.com/Unknwon/gowalker/utils"
)
var (
bitbucketPattern = regexp.MustCompile(`^bitbucket\.org/(?P<owner>[a-z0-9A-Z_.\-]+)/(?P<repo>[a-z0-9A-Z_.\-]+)(?P<dir>/[a-z0-9A-Z_.\-/]*)?$`)
bitbucketEtagRe = regexp.MustCompile(`^(hg|git)-`)
)
func getBitbucketDoc(client *http.Client, match map[string]string, savedEtag string) (*Package, error) {
if m := bitbucketEtagRe.FindStringSubmatch(savedEtag); m != nil {
match["vcs"] = m[1]
} else {
var repo struct {
Scm string
}
if err := httpGetJSON(client, expand("https://api.bitbucket.org/1.0/repositories/{owner}/{repo}", match), &repo); err != nil {
return nil, err
}
match["vcs"] = repo.Scm
}
tags := make(map[string]string)
for _, nodeType := range []string{"branches", "tags"} {
var nodes map[string]struct {
Node string
}
if err := httpGetJSON(client, expand("https://api.bitbucket.org/1.0/repositories/{owner}/{repo}/{0}", match, nodeType), &nodes); err != nil {
return nil, err
}
for t, n := range nodes {
tags[t] = n.Node
}
}
var err error
match["tag"], match["commit"], err = bestTag(tags, defaultTags[match["vcs"]])
if err != nil {
return nil, err
}
// Check revision tag.
etag := expand("{vcs}-{commit}", match)
if etag == savedEtag {
return nil, errNotModified
}
var node struct {
Files []struct {
Path string
}
Directories []string
}
if err := httpGetJSON(client, expand("https://api.bitbucket.org/1.0/repositories/{owner}/{repo}/src/{tag}{dir}/", match), &node); err != nil {
return nil, err
}
// Get source file data.
files := make([]*source, 0, 5)
for _, f := range node.Files {
_, name := path.Split(f.Path)
if utils.IsDocFile(name) {
files = append(files, &source{
name: name,
browseURL: expand("https://bitbucket.org/{owner}/{repo}/src/{tag}/{0}", match, f.Path),
rawURL: expand("https://api.bitbucket.org/1.0/repositories/{owner}/{repo}/raw/{tag}/{0}", match, f.Path),
})
}
}
if len(files) == 0 && len(node.Directories) == 0 {
return nil, NotFoundError{"Directory tree does not contain Go files and subdirs."}
}
// Fetch file from VCS.
if err := fetchFiles(client, files, nil); err != nil {
return nil, err
}
// Start generating data.
w := &walker{
lineFmt: "#cl-%d",
pdoc: &Package{
ImportPath: match["importPath"],
ProjectName: match["repo"],
Etag: etag,
Dirs: node.Directories,
},
}
return w.build(files)
}

2
i18n/en-US/usage_install.txt

@ -15,6 +15,8 @@ The install flags are:
force to update pakcages. force to update pakcages.
-e -e
download dependencies for examples. download dependencies for examples.
-s
download from sources.
The list flags accept a space-separated list of strings. To embed spaces The list flags accept a space-separated list of strings. To embed spaces
in an element in the list, surround it with either single or double quotes. in an element in the list, surround it with either single or double quotes.

5
install.go

@ -32,6 +32,7 @@ func init() {
"-d": false, "-d": false,
"-u": false, // Flag for 'go get'. "-u": false, // Flag for 'go get'.
"-e": false, "-e": false,
"-s": false,
} }
} }
@ -45,6 +46,10 @@ func printPrompt(flag string) {
fmt.Printf("You enabled download without installing.\n") fmt.Printf("You enabled download without installing.\n")
case "-e": case "-e":
fmt.Printf("You enabled download dependencies in example.\n") fmt.Printf("You enabled download dependencies in example.\n")
case "-e":
fmt.Printf("You enabled download dependencies in example.\n")
case "-s":
fmt.Printf("You enabled download from sources.\n")
} }
} }

Loading…
Cancel
Save