-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple git functions to test contract behaviour #202
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module ARCtrl.Contract.Git | ||
|
||
open ARCtrl.Contract | ||
|
||
let [<Literal>] git = @"git" | ||
let [<Literal>] defaultBranch = @"main" | ||
let [<Literal>] gitignoreFileName = @".gitignore" | ||
|
||
let gitWithArgs(arguments : string []) = CLITool.create(git,arguments) | ||
|
||
let createGitContractAt path arguments = Contract.createExecute(gitWithArgs(arguments),path) | ||
|
||
let createGitContract(arguments) = Contract.createExecute(gitWithArgs(arguments)) | ||
|
||
let gitignoreContract = Contract.createCreate(gitignoreFileName,DTOType.PlainText,DTO.Text ARCtrl.FileSystem.DefaultGitignore.dgi) | ||
|
||
type Init = | ||
|
||
static member init = "init" | ||
static member branchFlag = "-b" | ||
|
||
static member remote = @"remote" | ||
static member add = @"add" | ||
static member origin = @"origin" | ||
|
||
static member createInitContract(?branch : string) = | ||
let branch = Option.defaultValue defaultBranch branch | ||
createGitContract([|Init.init;Init.branchFlag;branch|]) | ||
|
||
static member createAddRemoteContract(remoteUrl : string) = | ||
createGitContract([|Init.remote;Init.add;Init.origin;remoteUrl|]) | ||
|
||
and Clone = | ||
|
||
static member clone = "clone" | ||
|
||
static member branchFlag = "-b" | ||
|
||
static member noLFSConfig = "-c \"filter.lfs.smudge = git-lfs smudge --skip -- %f\" -c \"filter.lfs.process = git-lfs filter-process --skip\"" | ||
|
||
static member formatRepoString username pass (url : string) = | ||
let comb = username + ":" + pass + "@" | ||
url.Replace("https://","https://" + comb) | ||
|
||
static member createCloneContract(remoteUrl : string,?merge : bool ,?branch : string,?token : string*string,?nolfs : bool) = | ||
let nolfs = Option.defaultValue false nolfs | ||
let merge = Option.defaultValue false merge | ||
let remoteUrl = | ||
match token with | ||
| Some (username,pass) -> Clone.formatRepoString username pass remoteUrl | ||
| None -> remoteUrl | ||
createGitContract([| | ||
Clone.clone | ||
if nolfs then Clone.noLFSConfig | ||
if branch.IsSome then Clone.branchFlag | ||
if branch.IsSome then branch.Value | ||
remoteUrl | ||
if merge then "." | ||
|]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
module ARCtrl.FileSystem.DefaultGitignore | ||
|
||
let dgi = """# ----- macos rules ----- | ||
# taken from https://github.com/github/gitignore/blob/main/Global/macOS.gitignore | ||
|
||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
|
||
|
||
|
||
|
||
# ----- windows rules ----- | ||
# taken from https://github.com/github/gitignore/blob/main/Global/Windows.gitignore | ||
|
||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
|
||
|
||
|
||
|
||
# ----- linux rules ----- | ||
# taken from https://github.com/github/gitignore/blob/main/Global/Linux.gitignore | ||
|
||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module TestingUtils | ||
|
||
#if FABLE_COMPILER | ||
open Fable.Mocha | ||
#else | ||
open Expecto | ||
#endif | ||
|
||
module Result = | ||
|
||
let getMessage (r : Result<'T,string>) = | ||
match r with | ||
| Ok _ -> "" | ||
| Error msg -> msg | ||
|
||
let private firstDiff s1 s2 = | ||
let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) | ||
let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) | ||
Seq.mapi2 (fun i s p -> i,s,p) s1 s2 | ||
|> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) | ||
|
||
/// Expects the `actual` sequence to equal the `expected` one. | ||
let mySequenceEqual actual expected message = | ||
match firstDiff actual expected with | ||
| _,None,None -> () | ||
| i,Some a, Some e -> | ||
failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." | ||
message i e a | ||
| i,None,Some e -> | ||
failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." | ||
message i e | ||
| i,Some a,None -> | ||
failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." | ||
message i a |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be part of the TestingUtil project?