~edwargix/git.sr.ht

f76de688455154b76c0dc7d206302ee8364281b8 — наб 4 years ago f81d358
Also create/delete git-daemon-export-ok in gitsrht-update-hook
2 files changed, 15 insertions(+), 0 deletions(-)

M gitsrht-update-hook/post-update.go
M gitsrht/types/__init__.py
M gitsrht-update-hook/post-update.go => gitsrht-update-hook/post-update.go +14 -0
@@ 6,6 6,7 @@ import (
	"fmt"
	"log"
	"os"
	"path"
	"strconv"
	"strings"
	"syscall"


@@ 143,6 144,18 @@ func parseUpdatables() (*string, *string) {
	return desc, vis
}

// Must match gitsrht/types/__init__.py#update_visibility()
func updateRepoVisibility(repoPath string, visibility string) {
	daemonPath := path.Join(repoPath, "git-daemon-export-ok")
	shouldExist := visibility == "public" || visibility == "unlisted"

	if shouldExist {
		os.Create(daemonPath)
	} else {
		os.Remove(daemonPath)
	}
}

func postUpdate() {
	var context PushContext
	refs := os.Args[1:]


@@ 190,6 203,7 @@ func postUpdate() {
	if err != nil {
		logger.Fatalf("Failed to fetch info from database: %v", err)
	}
	updateRepoVisibility(context.Repo.Path, dbinfo.Visibility)

	redisHost, ok := config.Get("sr.ht", "redis-host")
	if !ok {

M gitsrht/types/__init__.py => gitsrht/types/__init__.py +1 -0
@@ 22,6 22,7 @@ class Redirect(Base, BaseRedirectMixin):
class Repository(Base, BaseRepositoryMixin):
    _git_repo = None

    # Must match gitsrht-update-hook/post-update.go#updateRepoVisibility()
    def update_visibility(self):
        if not os.path.exists(self.path):
            # Repo dir not initialized yet