1 auto cred = getCredKeyFilePassPhrase("public", "private", "passphrase"); 2 3 switch (cred.credType) with (GitCredType) 4 { 5 case passphrase: 6 { 7 // throw when trying to cast to an inappropriate type 8 assertThrown!GitException(cred.get!plaintext); 9 10 // ditto 11 assertThrown!GitException(cred.get!GitCred_PlainText); 12 13 // use enum for the get template 14 auto cred1 = cred.get!passphrase; 15 assert(cred1.publicKey == "public"); 16 assert(cred1.privateKey == "private"); 17 assert(cred1.passPhrase == "passphrase"); 18 19 // or use a type 20 auto cred2 = cred.get!GitCred_KeyFilePassPhrase; 21 assert(cred2.publicKey == "public"); 22 assert(cred2.privateKey == "private"); 23 assert(cred2.passPhrase == "passphrase"); 24 25 break; 26 } 27 28 default: assert(0, text(cred.credType)); 29 }
Creates a new ssh key file and passphrase credential object. The supplied credential parameter will be internally duplicated.