1diff --git a/config.example.scfg b/config.example.scfg
2index 2ed13cd3141e7cb4451521ef61950560e369b770..5e475486aa8fdbd44dfa826a2dcefb0220954311 100644
3--- a/config.example.scfg
4+++ b/config.example.scfg
5@@ -5,6 +5,10 @@
6 root-readme /srv/git/README.md
7 syntax-highlight monokailight
8
9+# full hostname address plus protocol.
10+# This is going to be used to display full link (e.g.: clone link)
11+hostname https://domain.tld
12+
13 # if passphrase is empty the whole authentication, private/public repository
14 # and login UI will be disabled, and only public repository will be displayed.
15 passphrase $2a$14$VnB/ZcB1DUDkMnosRA6Y7.dj8h5eroslDxTeXlLwfQX/x86mh6WAq
16diff --git a/pkg/config/config.go b/pkg/config/config.go
17index 9dbf449a264d682aabc025b2d2b90f6a0e1ef828..c00586bc05d0814c85f32f5124202a999194486c 100644
18--- a/pkg/config/config.go
19+++ b/pkg/config/config.go
20@@ -51,6 +51,7 @@ Repositories []*GitRepositoryConfiguration
21 RootReadme string
22 Scans []*scan
23 SyntaxHighlight string
24+ Hostname string
25 }
26
27 // This is a per repository configuration.
28@@ -75,6 +76,7 @@ removeSuffix bool
29 repositories []*GitRepositoryConfiguration
30 rootReadme string
31 syntaxHighlight string
32+ hostname string
33 }
34 )
35
36@@ -95,6 +97,7 @@ listenAddr: config.ListenAddr,
37 passphrase: []byte(config.Passphrase),
38 repositories: config.Repositories,
39 rootReadme: config.RootReadme,
40+ hostname: config.Hostname,
41 syntaxHighlight: config.SyntaxHighlight,
42 removeSuffix: config.RemoveSuffix,
43 orderBy: parseOrderBy(config.OrderBy),
44@@ -115,6 +118,10 @@
45 // GetRootReadme returns root read path
46 func (c *ConfigurationRepository) GetRootReadme() string {
47 return c.rootReadme
48+}
49+
50+func (c *ConfigurationRepository) GetHostname() string {
51+ return c.hostname
52 }
53
54 func (c *ConfigurationRepository) GetOrderBy() OrderBy {
55@@ -219,6 +226,11 @@ if err != nil {
56 return nil, err
57 }
58
59+ err = setHostname(block, &config.Hostname)
60+ if err != nil {
61+ return nil, err
62+ }
63+
64 err = setListenAddr(block, &config.ListenAddr)
65 if err != nil {
66 return nil, err
67@@ -311,9 +323,14 @@ func defaultConfiguration() *configuration {
68 return &configuration{
69 Scans: defaultScans(),
70 RootReadme: "",
71+ Hostname: defaultHostname(),
72 ListenAddr: defaultAddr(),
73 Repositories: make([]*GitRepositoryConfiguration, 0),
74 }
75+}
76+
77+func defaultHostname() string {
78+ return "https://localhost:8080"
79 }
80
81 func defaultScans() []*scan {
82@@ -337,6 +354,11 @@
83 func setRootReadme(block scfg.Block, readme *string) error {
84 scanDir := block.Get("root-readme")
85 return setString(scanDir, readme)
86+}
87+
88+func setHostname(block scfg.Block, hostname *string) error {
89+ scanDir := block.Get("hostname")
90+ return setString(scanDir, hostname)
91 }
92
93 func setPassphrase(block scfg.Block, listenAddr *string) error {
94diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
95index 949238e511b755d33df8f9181fbcdb18263b6021..31cf1c07bf73fd1bbd9064cbaa341bea8640e18b 100644
96--- a/pkg/config/config_test.go
97+++ b/pkg/config/config_test.go
98@@ -25,6 +25,7 @@ Path: "/srv/git",
99 },
100 },
101 ListenAddr: defaultAddr(),
102+ Hostname: defaultHostname(),
103 Repositories: []*GitRepositoryConfiguration{},
104 },
105 },
106@@ -42,6 +43,7 @@ Path: "/srv/git",
107 },
108 },
109 ListenAddr: defaultAddr(),
110+ Hostname: defaultHostname(),
111 Repositories: []*GitRepositoryConfiguration{},
112 },
113 },
114@@ -51,6 +53,7 @@ config: `repository /srv/git/cerrado.git`,
115 expectedConfig: &configuration{
116 Scans: defaultScans(),
117 ListenAddr: defaultAddr(),
118+ Hostname: defaultHostname(),
119 Repositories: []*GitRepositoryConfiguration{
120 {
121 Name: "cerrado.git",
122@@ -74,6 +77,7 @@ }`,
123 expectedConfig: &configuration{
124 Scans: defaultScans(),
125 ListenAddr: defaultAddr(),
126+ Hostname: defaultHostname(),
127 Repositories: []*GitRepositoryConfiguration{
128 {
129 Name: "cerrado",
130@@ -91,6 +95,7 @@ config: ``,
131 expectedConfig: &configuration{
132 Scans: defaultScans(),
133 ListenAddr: defaultAddr(),
134+ Hostname: defaultHostname(),
135 Repositories: []*GitRepositoryConfiguration{},
136 },
137 },
138@@ -99,6 +104,7 @@ name: "complete listen",
139 config: `listen-addr unix://var/run/cerrado/cerrado.sock`,
140 expectedConfig: &configuration{
141 Scans: defaultScans(),
142+ Hostname: defaultHostname(),
143 ListenAddr: "unix://var/run/cerrado/cerrado.sock",
144 Repositories: []*GitRepositoryConfiguration{},
145 },
146@@ -112,6 +118,7 @@ aes-key 8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w==
147 syntax-highlight monokailight
148 order-by lastcommit-desc
149 remove-suffix true
150+hostname https://domain.tld
151
152 scan "/srv/git" {
153 public true
154@@ -138,6 +145,7 @@ AESKey: "8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w==",
155 SyntaxHighlight: "monokailight",
156 OrderBy: "lastcommit-desc",
157 RemoveSuffix: true,
158+ Hostname: "https://domain.tld",
159 Repositories: []*GitRepositoryConfiguration{
160 {
161 Name: "linux.git",