Browse Source

Adds support for .soloignore file

master
sloum 2 months ago
parent
commit
8350554915
  1. 8
      README.md
  2. 22
      solo

8
README.md

@ -8,7 +8,7 @@ A simple, single branch, version control system for individuals.
No one, really... me _maaaaybe_? It has been an educational exercise. However, if I add the concept of remotes I may end up using it a bit. Mot of my slope modules/projects consist of only a small handful of files, often in a single directory, that I do not develop collaboratively... which may suit solo well and vice versa.
## What does it do/how do you use it?
## Commands
solo essentially takes full backups of the current work tree and copies them to snapshots/commits in the `.solo` directory of a repository. It can then do a few simple things with those commits. All commands must be run from the repository root. The available commands are as follows:
@ -47,6 +47,12 @@ Reports what files have been added, deleted, or changed since the last commit.
Shows the actual changes between the current work tree and the last commit.
## Files
The file `.soloignore` can be placed in the repo root if you like. Each line in the file can be a relative path to a file, folder, or group of files (via globbing `*` or `**`). Any file listed in `.soloignore` will not be committed and will not show up for purposes of status or diff.
Initializing a repository will place a `.solo` folder in the root folder of the repository. This folder contains all of the solo data. If you ever want to stop using solo for a project or start from scratch with the given repo simply recursive delete the folder (`rm -rf ./.solo`). In general it is likely best to not mess around in the `.solo` folder, as the program will handle all of the edits and may become "confused" if things are not kept how it likes them ;)
## Dependencies
`solo` requires the [slope language](https://git.rawtext.club/slope-lang/slope) interpreter to be installed. It needs to be version `0.5.16` or higher as it uses some newer features (at time of writing). Other than that there are no additional slope modules needed. If you are needing to build the slope interpreter you will need a Go compiler >= version 1.16

22
solo

@ -275,8 +275,9 @@
(define solo-get-filepath-list (lambda (root-dir)
(define out [])
(define ignore (solo-get-ignored))
(for-each (lambda (p)
(if (and (not (path-is-dir? p)) (not (regex-match? "\\.solo" p)))
(if (and (not (path-is-dir? p)) (not (member? ignore p)) (not (regex-match? "\\.solo" p)))
(set! out (append out p))))
(path-glob (path-join root-dir "**")))
out))
@ -298,18 +299,24 @@
(define solo-files-changed (lambda (output ...)
(define first-path #f)
(define second-path (pwd))
(define homedir #t)
(cond
((null? ...) (! "'solo-changed-files' expects at least one commit to compare against"))
((equal? 1 (length ...)) (set! first-path (path-join (pwd) ".solo" "snapshots" (car ...))))
((> (length ...) 1)
(begin
(set! homedir #f)
(set! first-path (path-join (pwd) ".solo" "snapshots" (car ...)))
(set! second-path (path-join (pwd) ".solo" "snapshots" (car (cdr ...)))))))
(define ignored (solo-get-ignored))
(if homedir
(set! ignored (map (lambda (ln) (slice ln (+ (length (pwd)) 1))) ignored))
(set! ignored []))
(define first-list (filter (lambda (p) (not (equal? (path-base p) ".commit"))) (path-glob (path-join first-path "**"))))
(set! first-list (map (lambda (p) (slice p (+ (length first-path) 1))) first-list))
(define second-list (map (lambda (p) (slice p (+ (length second-path) 1))) (path-glob (path-join second-path "**"))))
(set! second-list (filter (lambda (p) (not (or (equal? (slice p 0 5) ".solo") (equal? p "") (equal? p ".commit")))) second-list))
(set! second-list (filter (lambda (p) (not (or (equal? (slice p 0 5) ".solo") (member? ignored p) (equal? p "") (equal? p ".commit")))) second-list))
(define out (map (lambda (p)
(cond
@ -329,7 +336,7 @@
out))
(define solo-do-diff (lambda (fileone filetwo file-out)
(subprocess ["diff" "-u" "-b" "-B" "--colo=always" fileone filetwo] file-out devnull)))
(subprocess ["diff" "-u" "-b" "-B" "--color=always" fileone filetwo] file-out devnull)))
(define solo-copy-file (lambda (from to)
(define in (file-open-read from))
@ -358,6 +365,15 @@
(close (write new-commit-hash (file-create head-path)))
parent-hash))
(define solo-get-ignored (lambda ()
(if (path-exists? (path-join (pwd) ".soloignore"))
(begin
(define files (string->list (open-read-close (path-join (pwd) ".soloignore")) "\n"))
(define out [(path-join (pwd) ".soloignore")])
(for-each (lambda (ln) (set! out (list-join out (path-glob (path-abs ln))))) (filter (lambda (l) (~bool l)) files))
out)
#f)))
(define open-read-close (lambda (path)
(define f (file-open-read path))
(if f

Loading…
Cancel
Save