summaryrefslogtreecommitdiffstats
Commit message (Expand)AuthorAgeFilesLines
* Merge pull request #2810 from maxlazio/fix_updated_and_createdUnknwon2016-03-116-10/+11
|\
| * Updated and created were appended with _unix. Fresh databases have only the n...Marin Jankovski2016-03-116-10/+11
|/
* Fix ref comment from commit create empty feedUnknwon2016-03-115-6/+9
* Merge pull request #2803 from Rukenshia/developUnknwon2016-03-101-1/+1
|\
| * Using HTML Description of repositories in the 'Explore' view. Fixes #2800Jan Christophersen2016-03-101-1/+1
* | Merge pull request #2802 from allonsy/developUnknwon2016-03-101-1/+1
|\ \
| * | readd 'dashboard' to titleAlec S2016-03-101-1/+1
|/ /
* | Merge pull request #2797 from allonsy/developUnknwon2016-03-101-2/+2
|\ \
| * \ Merge branch 'develop' of github.com:gogits/gogs into developAlec S2016-03-096-12/+20
| |\ \ | |/ / |/| |
* | | Merge pull request #2785 from Rukenshia/developUnknwon2016-03-091-4/+13
|\ \ \ | | |/ | |/|
| * | Allowing site admins to view private repositories in org/homeJan Christophersen2016-03-081-4/+13
* | | #2727 fix incompatible SQL in PostgreSQLUnknwon2016-03-095-8/+7
| | * fix indentationAlec S2016-03-091-1/+1
| | * Remove dashboard keyword from titleAlec S2016-03-091-1/+1
| | * change page titles for user and org dashesAlec S2016-03-091-2/+2
| |/ |/|
* | #2302 Replace time.Time with Unix Timestamp (int64)Unknwon2016-03-0919-125/+516
|/
* Update frontend resourcesUnknwon2016-03-0714-35/+59
* Fix pull request availability checkUnknwon2016-03-0613-43/+69
* Prepare releaseUnknwon2016-03-0610-349/+349
* Some minor changesUnknwon2016-03-066-107/+90
* Minor fix for #2772Unknwon2016-03-062-2/+2
* Merge pull request #2772 from OhDaeto/masterUnknwon2016-03-061-0/+37
|\
| * Merge pull request #1 from xDShot/patch-1OhDaeto2016-03-061-1/+1
| |\
| | * минимальные -> низкие (системные требования)xDShot2016-03-061-1/+1
| |/
| * Add ru-RU to home templateLourens2016-03-061-0/+37
* | Remove duplicated of codeUnknwon2016-03-064-56/+51
* | Minor fixes for #2766Unknwon2016-03-064-6/+5
* | Merge pull request #2766 from moltam/feature/delete-org-avatarUnknwon2016-03-065-6/+26
|\ \ | |/ |/|
| * Added: Ability to delete org avatar.Tamás Molnár2016-03-065-6/+26
|/
* #2623 fix wrong font for webhook historyUnknwon2016-03-052-139/+139
* Add Finnish supportUnknwon2016-03-0518-122/+1289
* #1146 finish new access rights for collaboratorsUnknwon2016-03-0522-182/+202
* #1146 finsih UI work for access mode of collaboratorsUnknwon2016-03-0516-164/+292
* Merge pull request #2762 from rom1504/patch-1Unknwon2016-03-051-1/+1
|\
| * Fix grammar in READMERomain Beaumont2016-03-051-1/+1
|/
* Update README notesUnknwon2016-03-051-5/+6
* #1597 fix activitity feeds for pull requestsUnknwon2016-03-0510-278/+338
* #1157 some avatar setting changesUnknwon2016-03-0510-46/+79
* Update localesUnknwon2016-03-0415-343/+628
* Merge pull request #2757 from joshfng/fix-fork-relative-urlUnknwon2016-03-042-2/+7
|\
| * Use relative url when showing forked fromJosh Frye2016-03-042-2/+7
* | #1597 fix pull request remote head can't update with force pushUnknwon2016-03-042-2/+7
* | #1597 fix premission logic check of pull requestUnknwon2016-03-041-7/+14
* | #2743 more fixes on SQL errorsUnknwon2016-03-041-6/+6
* | #1597 support pull requests in same repositoryUnknwon2016-03-0413-134/+95
* | Minor fixes for #2746Unknwon2016-03-048-723/+937
* | Merge pull request #2746 from joshfng/feature-delete-wiki-pagesUnknwon2016-03-046-906/+761
|\ \
| * | Update delete wiki page routeJosh Frye2016-03-042-2/+2
| * | Add ability to delete single wiki pages.Josh Frye2016-03-046-906/+761
| |/
* / #2743 and #2751 fix bad SQL generated by XORMUnknwon2016-03-045-19/+17
|/
an class="p">.NewCommand(ctx, "symbolic-ref", "HEAD", git.BranchPrefix+DefaultBranch).RunStdString(&git.RunOpts{Dir: repo.WikiPath()}); err != nil { return fmt.Errorf("unable to set default wiki branch to master: %w", err) } return nil } // prepareGitPath try to find a suitable file path with file name by the given raw wiki name. // return: existence, prepared file path with name, error func prepareGitPath(gitRepo *git.Repository, wikiPath WebPath) (bool, string, error) { unescaped := string(wikiPath) + ".md" gitPath := WebPathToGitPath(wikiPath) // Look for both files filesInIndex, err := gitRepo.LsTree(DefaultBranch, unescaped, gitPath) if err != nil { if strings.Contains(err.Error(), "Not a valid object name master") { return false, gitPath, nil } log.Error("%v", err) return false, gitPath, err } foundEscaped := false for _, filename := range filesInIndex { switch filename { case unescaped: // if we find the unescaped file return it return true, unescaped, nil case gitPath: foundEscaped = true } } // If not return whether the escaped file exists, and the escaped filename to keep backwards compatibility. return foundEscaped, gitPath, nil } // updateWikiPage adds a new page or edits an existing page in repository wiki. func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldWikiName, newWikiName WebPath, content, message string, isNew bool) (err error) { if err = validateWebPath(newWikiName); err != nil { return err } wikiWorkingPool.CheckIn(fmt.Sprint(repo.ID)) defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID)) if err = InitWiki(ctx, repo); err != nil { return fmt.Errorf("InitWiki: %w", err) } hasMasterBranch := git.IsBranchExist(ctx, repo.WikiPath(), DefaultBranch) basePath, err := repo_module.CreateTemporaryPath("update-wiki") if err != nil { return err } defer func() { if err := repo_module.RemoveTemporaryPath(basePath); err != nil { log.Error("Merge: RemoveTemporaryPath: %s", err) } }() cloneOpts := git.CloneRepoOptions{ Bare: true, Shared: true, } if hasMasterBranch { cloneOpts.Branch = DefaultBranch } if err := git.Clone(ctx, repo.WikiPath(), basePath, cloneOpts); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) return fmt.Errorf("failed to clone repository: %s (%w)", repo.FullName(), err) } gitRepo, err := git.OpenRepository(ctx, basePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", basePath, err) return fmt.Errorf("failed to open new temporary repository in: %s %w", basePath, err) } defer gitRepo.Close() if hasMasterBranch { if err := gitRepo.ReadTreeToIndex("HEAD"); err != nil { log.Error("Unable to read HEAD tree to index in: %s %v", basePath, err) return fmt.Errorf("fnable to read HEAD tree to index in: %s %w", basePath, err) } } isWikiExist, newWikiPath, err := prepareGitPath(gitRepo, newWikiName) if err != nil { return err } if isNew { if isWikiExist { return repo_model.ErrWikiAlreadyExist{ Title: newWikiPath, } } } else { // avoid check existence again if wiki name is not changed since gitRepo.LsFiles(...) is not free. isOldWikiExist := true oldWikiPath := newWikiPath if oldWikiName != newWikiName { isOldWikiExist, oldWikiPath, err = prepareGitPath(gitRepo, oldWikiName) if err != nil { return err } } if isOldWikiExist { err := gitRepo.RemoveFilesFromIndex(oldWikiPath) if err != nil { log.Error("%v", err) return err } } } // FIXME: The wiki doesn't have lfs support at present - if this changes need to check attributes here objectHash, err := gitRepo.HashObject(strings.NewReader(content)) if err != nil { log.Error("%v", err) return err } if err := gitRepo.AddObjectToIndex("100644", objectHash, newWikiPath); err != nil { log.Error("%v", err) return err } tree, err := gitRepo.WriteTree() if err != nil { log.Error("%v", err) return err } commitTreeOpts := git.CommitTreeOpts{ Message: message, } committer := doer.NewGitSig() sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo.WikiPath(), doer) if sign { commitTreeOpts.KeyID = signingKey if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { committer = signer } } else { commitTreeOpts.NoGPGSign = true } if hasMasterBranch { commitTreeOpts.Parents = []string{"HEAD"} } commitHash, err := gitRepo.CommitTree(doer.NewGitSig(), committer, tree, commitTreeOpts) if err != nil { log.Error("%v", err) return err } if err := git.Push(gitRepo.Ctx, basePath, git.PushOptions{ Remote: DefaultRemote, Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, DefaultBranch), Env: repo_module.FullPushingEnvironment( doer, doer, repo, repo.Name+".wiki", 0, ), }); err != nil { log.Error("%v", err) if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) { return err } return fmt.Errorf("Push: %w", err) } return nil } // AddWikiPage adds a new wiki page with a given wikiPath. func AddWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, wikiName WebPath, content, message string) error { return updateWikiPage(ctx, doer, repo, "", wikiName, content, message, true) } // EditWikiPage updates a wiki page identified by its wikiPath, // optionally also changing wikiPath. func EditWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldWikiName, newWikiName WebPath, content, message string) error { return updateWikiPage(ctx, doer, repo, oldWikiName, newWikiName, content, message, false) } // DeleteWikiPage deletes a wiki page identified by its path. func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, wikiName WebPath) (err error) { wikiWorkingPool.CheckIn(fmt.Sprint(repo.ID)) defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID)) if err = InitWiki(ctx, repo); err != nil { return fmt.Errorf("InitWiki: %w", err) } basePath, err := repo_module.CreateTemporaryPath("update-wiki") if err != nil { return err } defer func() { if err := repo_module.RemoveTemporaryPath(basePath); err != nil { log.Error("Merge: RemoveTemporaryPath: %s", err) } }() if err := git.Clone(ctx, repo.WikiPath(), basePath, git.CloneRepoOptions{ Bare: true, Shared: true, Branch: DefaultBranch, }); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) return fmt.Errorf("failed to clone repository: %s (%w)", repo.FullName(), err) } gitRepo, err := git.OpenRepository(ctx, basePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", basePath, err) return fmt.Errorf("failed to open new temporary repository in: %s %w", basePath, err) } defer gitRepo.Close() if err := gitRepo.ReadTreeToIndex("HEAD"); err != nil { log.Error("Unable to read HEAD tree to index in: %s %v", basePath, err) return fmt.Errorf("unable to read HEAD tree to index in: %s %w", basePath, err) } found, wikiPath, err := prepareGitPath(gitRepo, wikiName) if err != nil { return err } if found { err := gitRepo.RemoveFilesFromIndex(wikiPath) if err != nil { return err } } else { return os.ErrNotExist } // FIXME: The wiki doesn't have lfs support at present - if this changes need to check attributes here tree, err := gitRepo.WriteTree() if err != nil { return err } message := fmt.Sprintf("Delete page %q", wikiName) commitTreeOpts := git.CommitTreeOpts{ Message: message, Parents: []string{"HEAD"}, } committer := doer.NewGitSig() sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo.WikiPath(), doer) if sign { commitTreeOpts.KeyID = signingKey if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { committer = signer } } else { commitTreeOpts.NoGPGSign = true } commitHash, err := gitRepo.CommitTree(doer.NewGitSig(), committer, tree, commitTreeOpts) if err != nil { return err } if err := git.Push(gitRepo.Ctx, basePath, git.PushOptions{ Remote: DefaultRemote, Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, DefaultBranch), Env: repo_module.PushingEnvironment(doer, repo), }); err != nil { if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) { return err } return fmt.Errorf("Push: %w", err) } return nil } // DeleteWiki removes the actual and local copy of repository wiki. func DeleteWiki(ctx context.Context, repo *repo_model.Repository) error { if err := repo_model.UpdateRepositoryUnits(repo, nil, []unit.Type{unit.TypeWiki}); err != nil { return err } system_model.RemoveAllWithNotice(ctx, "Delete repository wiki", repo.WikiPath()) return nil }