This commit is contained in:
Liang Ding 2014-09-05 11:07:29 +08:00
parent fcfe3eb221
commit 932d472c0d
7 changed files with 16 additions and 21 deletions

View File

@ -28,8 +28,8 @@ type conf struct {
StaticPath string
MaxProcs int
RuntimeMode string
Repos string
UserRepos string
Workspace string
UserWorkspaces string
Users []User
}
@ -91,8 +91,8 @@ func Load() {
pwd = pwd[:strings.LastIndex(pwd, string(os.PathSeparator))]
glog.Infof("pwd [%s]", pwd)
Wide.Repos = strings.Replace(Wide.Repos, "{pwd}", pwd, 1)
Wide.UserRepos = strings.Replace(Wide.UserRepos, "{pwd}", pwd, 1)
Wide.Workspace = strings.Replace(Wide.Workspace, "{pwd}", pwd, 1)
Wide.UserWorkspaces = strings.Replace(Wide.UserWorkspaces, "{pwd}", pwd, 1)
glog.Info("Conf: \n" + string(bytes))
}

View File

@ -9,8 +9,8 @@
"StaticPath": "",
"MaxProcs": 4,
"RuntimeMode": "dev",
"Repos": "{pwd}/data/workspace/src",
"UserRepos": "{pwd}/data/user_workspaces/{user}/src",
"Workspace": "{pwd}/data/workspace",
"UserWorkspaces": "{pwd}/data/user_workspaces",
"Users": [
{
"Name": "admin",

View File

@ -11,7 +11,6 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
@ -151,15 +150,13 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
// glog.Infof("offset: %d", offset)
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
userWorkspace := userRepos[:strings.LastIndex(userRepos, "/src")]
userWorkspace = filepath.FromSlash(userWorkspace)
userWorkspace := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username
//glog.Infof("User [%s] workspace [%s]", username, userWorkspace)
userLib := userWorkspace + string(os.PathSeparator) + "pkg" + string(os.PathSeparator) +
runtime.GOOS + "_" + runtime.GOARCH
masterWorkspace := conf.Wide.Repos[:strings.LastIndex(conf.Wide.Repos, "/src")]
masterWorkspace = filepath.FromSlash(masterWorkspace)
masterWorkspace := conf.Wide.Workspace
//glog.Infof("Master workspace [%s]", masterWorkspace)
masterLib := masterWorkspace + string(os.PathSeparator) + "pkg" + string(os.PathSeparator) +
runtime.GOOS + "_" + runtime.GOARCH

View File

@ -21,8 +21,7 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
session, _ := user.Session.Get(r, "wide-session")
username := session.Values["username"].(string)
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
userRepos := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username + string(os.PathSeparator) + "src"
root := FileNode{"projects", userRepos, "d", []*FileNode{}}
fileInfo, _ := os.Lstat(userRepos)

View File

@ -231,8 +231,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
}
func setCmdEnv(cmd *exec.Cmd, username string) {
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
userWorkspace := userRepos[:strings.LastIndex(userRepos, "/src")]
userWorkspace := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username
cmd.Env = append(cmd.Env,
"GOPATH="+userWorkspace,

View File

@ -97,8 +97,8 @@ func pipeCommands(commands ...*exec.Cmd) string {
func setCmdEnv(cmd *exec.Cmd) {
// TODO: 使用用户自己的仓库路径设置 GOPATH
cmd.Env = append(cmd.Env, "TERM=xterm", "GOPATH="+conf.Wide.Repos,
cmd.Env = append(cmd.Env, "TERM=xterm", "GOPATH="+conf.Wide.Workspace,
"GOROOT="+os.Getenv("GOROOT"))
cmd.Dir = conf.Wide.Repos
cmd.Dir = conf.Wide.Workspace
}

View File

@ -6,7 +6,7 @@ import (
"github.com/b3log/wide/util"
"github.com/golang/glog"
"net/http"
"strings"
"os"
)
const (
@ -47,11 +47,11 @@ func InitGitRepos(w http.ResponseWriter, r *http.Request) {
session, _ := Session.Get(r, "wide-session")
username := session.Values["username"].(string)
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
userRepos := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username + string(os.PathSeparator) + "src"
// TODO: git clone
glog.Infof("Git Cloned from [%s] to [%s]", conf.Wide.Repos, userRepos)
glog.Infof("Git Cloned from [%s] to [%s]", conf.Wide.Workspace+string(os.PathSeparator)+"src", userRepos)
}
func addUser(username, password string) string {