// InitRepository initializes README and .gitignore if needed. | // InitRepository initializes README and .gitignore if needed. | ||||
func initRepository(e Engine, repoPath string, u *User, repo *Repository, initReadme bool, repoLang, license string) error { | func initRepository(e Engine, repoPath string, u *User, repo *Repository, initReadme bool, repoLang, license string) error { | ||||
// Somehow the directory could exist. | |||||
if com.IsExist(repoPath) { | |||||
return fmt.Errorf("initRepository: path already exists: %s", repoPath) | |||||
} | |||||
// Init bare new repository. | // Init bare new repository. | ||||
os.MkdirAll(repoPath, os.ModePerm) | os.MkdirAll(repoPath, os.ModePerm) | ||||
_, stderr, err := process.ExecDir(-1, repoPath, | _, stderr, err := process.ExecDir(-1, repoPath, | ||||
fmt.Sprintf("initRepository(git init --bare): %s", repoPath), | fmt.Sprintf("initRepository(git init --bare): %s", repoPath), | ||||
"git", "init", "--bare") | "git", "init", "--bare") | ||||
if err != nil { | if err != nil { | ||||
return errors.New("git init --bare: " + stderr) | |||||
return fmt.Errorf("git init --bare: %s", err) | |||||
} | } | ||||
if err := createUpdateHook(repoPath); err != nil { | if err := createUpdateHook(repoPath); err != nil { |
} | } | ||||
stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "tag", "-l") | stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "tag", "-l") | ||||
if err != nil { | if err != nil { | ||||
return nil, errors.New(stderr) | |||||
return nil, concatenateError(err, stderr) | |||||
} | } | ||||
tags := strings.Split(stdout, "\n") | tags := strings.Split(stdout, "\n") | ||||
return tags[:len(tags)-1], nil | return tags[:len(tags)-1], nil |
import ( | import ( | ||||
"bytes" | "bytes" | ||||
"container/list" | "container/list" | ||||
"fmt" | |||||
"os" | "os" | ||||
"path/filepath" | "path/filepath" | ||||
"strings" | "strings" | ||||
} | } | ||||
return !f.IsDir() | return !f.IsDir() | ||||
} | } | ||||
func concatenateError(err error, stderr string) error { | |||||
if len(stderr) == 0 { | |||||
return err | |||||
} | |||||
return fmt.Errorf("%v: %s", err, stderr) | |||||
} |
org := ctx.Org.Organization | org := ctx.Org.Organization | ||||
ctx.Data["Org"] = org | ctx.Data["Org"] = org | ||||
// Force redirection when username is actually a user. | |||||
if !org.IsOrganization() { | |||||
ctx.Redirect("/" + org.Name) | |||||
return | |||||
} | |||||
if ctx.IsSigned { | if ctx.IsSigned { | ||||
ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id) | ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id) | ||||
if ctx.Org.IsOwner { | if ctx.Org.IsOwner { |