tangled
alpha
login
or
join now
bad-example.com
/
core
forked from
tangled.org/core
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
allow choosing default branch on UI
oppi.li
11 months ago
b87fd81f
639b3186
+24
-5
4 changed files
expand all
collapse all
unified
split
appview
pages
templates
repo
new.html
state
signer.go
state.go
knotserver
routes.go
+10
appview/pages/templates/repo/new.html
···
16
16
class="w-full max-w-md"
17
17
/>
18
18
<p class="text-sm text-gray-500">All repositories are publicly visible.</p>
19
19
+
20
20
+
<label for="name" class="block uppercase font-bold text-sm">Default branch</label>
21
21
+
<input
22
22
+
type="text"
23
23
+
id="branch"
24
24
+
name="branch"
25
25
+
required
26
26
+
class="w-full max-w-md"
27
27
+
/>
28
28
+
<p class="text-sm text-gray-500">The default branch is <span class="font-bold">main</span></p>
19
29
</div>
20
30
21
31
<fieldset class="space-y-3">
+6
-3
appview/state/signer.go
···
77
77
return s.client.Do(req)
78
78
}
79
79
80
80
-
func (s *SignedClient) NewRepo(did, repoName string) (*http.Response, error) {
80
80
+
func (s *SignedClient) NewRepo(did, repoName, defaultBranch string) (*http.Response, error) {
81
81
const (
82
82
Method = "PUT"
83
83
Endpoint = "/repo/new"
84
84
)
85
85
86
86
body, _ := json.Marshal(map[string]interface{}{
87
87
-
"did": did,
88
88
-
"name": repoName,
87
87
+
"did": did,
88
88
+
"name": repoName,
89
89
+
"default_branch": defaultBranch,
89
90
})
91
91
+
92
92
+
fmt.Println(body)
90
93
91
94
req, err := s.newRequest(Method, Endpoint, body)
92
95
if err != nil {
+6
-1
appview/state/state.go
···
508
508
return
509
509
}
510
510
511
511
+
defaultBranch := r.FormValue("branch")
512
512
+
if defaultBranch == "" {
513
513
+
defaultBranch = "main"
514
514
+
}
515
515
+
511
516
ok, err := s.enforcer.E.Enforce(user.Did, domain, domain, "repo:create")
512
517
if err != nil || !ok {
513
518
s.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.")
···
526
531
return
527
532
}
528
533
529
529
-
resp, err := client.NewRepo(user.Did, repoName)
534
534
+
resp, err := client.NewRepo(user.Did, repoName, defaultBranch)
530
535
if err != nil {
531
536
s.pages.Notice(w, "repo", "Failed to create repository on knot server.")
532
537
return
+2
-1
knotserver/routes.go
···
505
505
return
506
506
}
507
507
508
508
+
log.Println("branch", data.DefaultBranch)
508
509
if data.DefaultBranch == "" {
509
509
-
data.DefaultBranch = "main"
510
510
+
data.DefaultBranch = h.c.Repo.MainBranch
510
511
}
511
512
512
513
did := data.Did