Detailed changes
@@ -46,7 +46,7 @@ func TestScript(t *testing.T) {
Cmds: map[string]func(ts *testscript.TestScript, neg bool, args []string){
"soft": cmdSoft(admin1.Signer()),
"git": cmdGit(key),
- "mkreadme": cmdMkReadme,
+ "mkfile": cmdMkfile,
"dos2unix": cmdDos2Unix,
},
Setup: func(e *testscript.Env) error {
@@ -211,12 +211,15 @@ func cmdGit(key string) func(ts *testscript.TestScript, neg bool, args []string)
}
}
-func cmdMkReadme(ts *testscript.TestScript, neg bool, args []string) {
- if len(args) != 1 {
- ts.Fatalf("usage: mkreadme path")
+func cmdMkfile(ts *testscript.TestScript, neg bool, args []string) {
+ if len(args) < 2 {
+ ts.Fatalf("usage: mkfile path content")
}
- content := []byte("# example\ntest project")
- check(ts, os.WriteFile(ts.MkAbs(args[0]), content, 0o644), neg)
+ check(ts, os.WriteFile(
+ ts.MkAbs(args[0]),
+ []byte(strings.Join(args[1:], " ")),
+ 0o644,
+ ), neg)
}
func check(ts *testscript.TestScript, err error, neg bool) {
@@ -0,0 +1,25 @@
+# vi: set ft=conf
+[windows] dos2unix help.txt
+
+soft --help
+cmpenv stdout help.txt
+
+-- help.txt --
+Soft Serve is a self-hostable Git server for the command line.
+
+Usage:
+ ssh -p $SSH_PORT localhost [command]
+
+Available Commands:
+ help Help about any command
+ info Show your info
+ pubkey Manage your public keys
+ repo Manage repositories
+ set-username Set your username
+ settings Manage server settings
+ user Manage users
+
+Flags:
+ -h, --help help for this command
+
+Use "ssh -p $SSH_PORT localhost [command] --help" for more information about a command.
@@ -0,0 +1,51 @@
+# vi: set ft=conf
+
+# convert crlf to lf on windows
+[windows] dos2unix blob1.txt blob2.txt blob3.txt
+
+# create a repo
+soft repo create repo1
+
+# clone repo
+git clone ssh://localhost:$SSH_PORT/repo1 repo1
+
+# create some files, commits, tags...
+mkfile ./repo1/README.md '# Hello\n\nwelcome'
+mkfile ./repo1/main.go 'package main\nconst foo = 2\n'
+mkfile ./repo1/.hidden ''
+mkdir ./repo1/folder
+mkdir ./repo1/.folder
+mkfile ./repo1/folder/lib.c '//#include <stdio.h>'
+git -C repo1 add -A
+git -C repo1 commit -m 'first'
+git -C repo1 push origin HEAD
+
+# print root blob
+soft repo blob repo1 README.md
+cmp stdout blob1.txt
+
+# print file blob with revision with line numbers and colors
+soft repo blob repo1 master main.go -l -c
+cmp stdout blob2.txt
+
+
+# print file blob with revision within folder with lineno
+soft repo blob repo1 master folder/lib.c -l
+cmp stdout blob3.txt
+
+# print blob of folder that does not exist
+! soft repo blob repo1 folder/nope.txt
+! stdout .
+stderr 'revision does not exist'
+
+# print blob of bad revision
+! soft repo blob repo1 badrev README.md
+! stdout .
+stderr 'revision does not exist'
+
+-- blob1.txt --
+# Hello\n\nwelcome
+-- blob2.txt --
+ [38;5;239m1[0m [38;5;236m│[0m [38;5;204m[0m[38;5;204mpackage[0m main[38;5;255m\[0mnconst foo [38;5;187m=[0m [38;5;85m2[0m[38;5;255m\[0mn
+-- blob3.txt --
+ 1 │ //#include <stdio.h>
@@ -11,12 +11,14 @@ soft repo private repo1
stdout true
soft repo description repo1
stdout 'description'
+soft repo project-name repo1
+stdout 'repo1'
# clone repo
git clone ssh://localhost:$SSH_PORT/repo1 repo1
# create some files, commits, tags...
-mkreadme ./repo1/README.md
+mkfile ./repo1/README.md '# Project\nfoo'
git -C repo1 add -A
git -C repo1 commit -m 'first'
git -C repo1 tag v0.1.0
@@ -69,10 +71,9 @@ soft repo branch list repo1
stdout branch1
-- tree.txt --
--rw-r--r-- 22 B README.md
+-rw-r--r-- 14 B README.md
-- readme.md --
-# example
-test project
+# Project\nfoo
-- branch_list.1.txt --
branch1
master
@@ -0,0 +1,8 @@
+# vi: set ft=conf
+
+soft repo create repo1
+soft repo create repo-to-delete
+soft repo delete repo-to-delete
+soft repo delete nope # repo delete never fails
+soft repo list
+stdout 'repo1'
@@ -10,12 +10,12 @@ soft repo create repo1
git clone ssh://localhost:$SSH_PORT/repo1 repo1
# create some files, commits, tags...
-mkreadme ./repo1/README.md
-mkreadme ./repo1/b.md
-mkreadme ./repo1/.hidden
+mkfile ./repo1/README.md '# Hello'
+mkfile ./repo1/b.md 'hi'
+mkfile ./repo1/.hidden ''
mkdir ./repo1/folder
mkdir ./repo1/.folder
-mkreadme ./repo1/folder/aa.md
+mkfile ./repo1/folder/aa.md 'hello'
git -C repo1 add -A
git -C repo1 commit -m 'first'
git -C repo1 push origin HEAD
@@ -44,10 +44,10 @@ stderr 'revision does not exist'
-- tree1.txt --
drwxrwxrwx - folder
--rw-r--r-- 22 B .hidden
--rw-r--r-- 22 B README.md
--rw-r--r-- 22 B b.md
+-rw-r--r-- - .hidden
+-rw-r--r-- 7 B README.md
+-rw-r--r-- 2 B b.md
-- tree2.txt --
--rw-r--r-- 22 B aa.md
+-rw-r--r-- 5 B aa.md
-- tree3.txt --
--rw-r--r-- 22 B b.md
+-rw-r--r-- 2 B b.md
@@ -13,7 +13,7 @@ stdout 'false.*'
soft settings anon-access
stdout 'read-only.*'
-# chaneg anon-access to all available options, and check them
+# change anon-access to all available options, and check them
soft settings anon-access no-access
soft settings anon-access
stdout 'no-access.*'
@@ -29,3 +29,9 @@ stdout 'read-write.*'
soft settings anon-access admin-access
soft settings anon-access
stdout 'admin-access.*'
+
+# try to set a bad access
+! soft settings anon-access nope
+! stdout .
+stderr .
+