mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-14 06:07:14 +02:00
Enforce git config on startup (#383)
This commit is contained in:
@ -33,8 +33,6 @@ FROM base AS dev
|
|||||||
EXPOSE 6157 2222 16157
|
EXPOSE 6157 2222 16157
|
||||||
VOLUME /opengist
|
VOLUME /opengist
|
||||||
|
|
||||||
RUN git config --global --add safe.directory /opengist
|
|
||||||
|
|
||||||
CMD ["make", "watch"]
|
CMD ["make", "watch"]
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ RUN apk update && \
|
|||||||
libstdc++
|
libstdc++
|
||||||
|
|
||||||
RUN addgroup -S opengist && \
|
RUN addgroup -S opengist && \
|
||||||
adduser -S -G opengist -H -s /bin/ash -g 'Opengist User' opengist
|
adduser -S -G opengist -s /bin/ash -g 'Opengist User' opengist
|
||||||
|
|
||||||
COPY --from=build --chown=opengist:opengist /opengist/config.yml config.yml
|
COPY --from=build --chown=opengist:opengist /opengist/config.yml config.yml
|
||||||
|
|
||||||
|
@ -92,6 +92,10 @@ func Initialize(ctx *cli.Context) {
|
|||||||
"Current git version: " + gitVersion)
|
"Current git version: " + gitVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := git.InitGitConfig(); err != nil {
|
||||||
|
log.Fatal().Err(err).Send()
|
||||||
|
}
|
||||||
|
|
||||||
homePath := config.GetHomeDir()
|
homePath := config.GetHomeDir()
|
||||||
log.Info().Msg("Data directory: " + homePath)
|
log.Info().Msg("Data directory: " + homePath)
|
||||||
|
|
||||||
|
23
internal/git/config.go
Normal file
23
internal/git/config.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package git
|
||||||
|
|
||||||
|
import "os/exec"
|
||||||
|
|
||||||
|
func InitGitConfig() error {
|
||||||
|
configs := map[string]string{
|
||||||
|
"receive.advertisePushOptions": "true",
|
||||||
|
"safe.directory": "*",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range configs {
|
||||||
|
if err := setGitConfig(key, value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setGitConfig(key, value string) error {
|
||||||
|
cmd := exec.Command("git", "config", "--global", key, value)
|
||||||
|
return cmd.Run()
|
||||||
|
}
|
Reference in New Issue
Block a user