alpha
Login
or
Join now
4uffin.bsky.social
/
core
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
My own copy of Tangled :)
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
allow choosing default branch on UI
author
Akshay
date
1 year ago
(Mar 3, 2025, 4:10 PM UTC)
commit
b87fd81f
b87fd81f0a2a475651ba67f3350d68f08a65df7e
parent
639b3186
639b3186a3c897547a85a8522730028eef8ce0e1
+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
Reviewed
···
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
Reviewed
···
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
Reviewed
···
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
Reviewed
···
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