public bool Clone_Or_Open_O2_Platform_Scripts_Repository() { var sourceRepository = O2_Platform_Consts.GIT_HUB_O2_PLATFORM_SCRIPTS; var targetFolder = O2_Platform_Config.Current.Folder_Scripts; nGit = new API_NGit().open_or_Clone(sourceRepository, targetFolder); return nGit.isGitRepository(); }
public GitLibraryController() { if (TM_Xml_Database_Git.Current_Git.isNull()) new TM_Xml_Database_Git().setupGitSupport(); nGit = TM_Xml_Database_Git.Current_Git.NGits.first(); }
public void Create_Repo_Add_Files_Check_Head() { var nGit = new API_NGit(); var tempRepo = "_tempRepo".tempDir(true); "TestRepo is: {0}".info(tempRepo); //Creating a local temp Repo Assert.IsFalse(tempRepo.isGitRepository() , "Should not be a repo"); nGit.init(tempRepo); Assert.IsTrue(tempRepo.isGitRepository(), "Should be a repo"); Assert.IsNull(nGit.head()); //Adding a file (using method 1) nGit.file_Create("testFile.txt", "some Text"); nGit.add_and_Commit_using_Status(); var head1 = nGit.head(); Assert.IsNotNull(head1); //Adding another file (using method 2) nGit.file_Create("testFile2.txt", "some Text"); nGit.add("testFile2.txt"); nGit.commit("Adding Another file"); //making sure the head has changed var head2 = nGit.head(); Assert.AreNotEqual(head1,head2); nGit.delete_Repository_And_Files(); }
public void clone() { //git_Clonen(); // already triggers methods funcionality //test Exception handing var nGit = new API_NGit(); Assert.IsNull(nGit.clone(null,null)); Assert.IsInstanceOf<InvalidRemoteException>(nGit.Last_Exception); Assert.IsNull(nGit.clone(null,"".tempDir(false))); }
public void delete_Repository_And_Files() { var localRepo = "localRepo".tempDir(); var nGit_Repo = localRepo.git_Init(); nGit_Repo.file_Create_Random_File(); nGit_Repo.add_and_Commit_using_Status(); nGit_Repo.delete_Repository_And_Files(); Assert.IsFalse(localRepo.isGitRepository()); Assert.IsFalse(localRepo.dirExists()); //check exceptions Assert.IsFalse((null as API_NGit).delete_Repository_And_Files()); Assert.IsFalse((null as API_NGit).delete_Repository()); var badNGitObject = new API_NGit { Path_Local_Repository = localRepo }; Assert.IsFalse(badNGitObject.delete_Repository()); }
public void Script_Run_AllScripts() { UserGroup.Admin.assert(); TmRest.TBot_Run("Git"); // trigger unpack of NGit and Sharpen dlls var fluentSharpGit = new API_NGit(); Assert.NotNull(fluentSharpGit, "fluentSharpGit was null"); // Load dlls as required by some TBot pages: "System.Xml.Linq".assembly().assert_Not_Null(); // Import Legacy Users "FluentSharp.Xml".assembly().assert_Not_Null(); // Import Legacy Users "TeamMentor.AspNet".assembly().assert_Not_Null(); // DebugInfo //"System.Web" .assembly().assert_Not_Null(); // IIS Sessions var tbotBrain = new TBot_Brain(TmRest); foreach (var scriptName in tbotBrain.scriptsNames()) { if(scriptName.equals("GitDiff_UserData_Commit", "GitDiff_UserData_File")) // there is a prob is this Tbot page (currently not exposed to users) continue; //if (scriptName != "Json_UserTags") continue; "================= Executing TBot script: {0}".info(scriptName); var html = tbotBrain.ExecuteRazorPage(scriptName); //"View_Emails_Sent"); Assert.IsNotNull(html, "for :{0}".format(scriptName)); var compileError = html.contains("Unable to compile template"); if (compileError) { html.info(); Assert.Fail("Failed to compile: {0}".format(scriptName)); } var executionError = html.contains("Opps: Something went wrong:"); if (executionError) { html.info(); Assert.Fail("Execution error: on {0}".format(scriptName)); } } //"test webBrowser".popupWindow().add_WebBrowser().set_Html(html).waitForClose(); }
public static TM_UserData_Git pushUserRepository(this TM_UserData_Git userData, API_NGit nGit) { var tmServer = userData.FileStorage.tmServer(); if (tmServer.isNull()) return userData; if (tmServer.Git.UserData_Auto_Push.isFalse()) //skip if this is set return userData; if (WebUtils.runningOnLocalHost()) //don't push local changes in order to prevent git merge conflicts { "[TM_UserData] [triggerGitCommit] skipping because it is a local request and getGitUserConfigFile is set".info(); return userData; } TM_UserData.GitPushThread = O2Thread.mtaThread( ()=>{ var start = DateTime.Now; "[TM_UserData] [GitPush] Start".info(); nGit.push(); "[TM_UserData] [GitPush] in ".info(start.duration_To_Now()); }); return userData; }
public void setUp() { UserGroup.Admin.assert(); //create TM_FileStorage on temp Custom_WebRoot for this TestFixture TM_FileStorage.Custom_WebRoot = "custom_WebRoot".tempDir(); tmFileStorage = new TM_FileStorage(false); tmFileStorage.set_WebRoot() .set_Path_XmlDatabase() .tmServer_Load() .set_Path_UserData() .load_UserData(); tmFileStorage.hook_Events_TM_UserData(); tmXmlDatabase = tmFileStorage.TMXmlDatabase .assert_Not_Null(); userData = tmFileStorage.UserData .assert_Not_Null(); tmServer = tmFileStorage.Server .assert_Not_Null(); tmFileStorage.Path_XmlDatabase.assert_Folder_Exists(); tmFileStorage.Path_UserData .assert_Folder_Exists(); userDataGit = tmFileStorage .setup_UserData_Git_Support(); // adds Git Support for UserData repos tmFileStorage.Path_UserData.isGitRepository().assert_True(); Assert.NotNull(tmFileStorage.Server.userData_Config()); userData .createDefaultAdminUser(); userDataGit.triggerGitCommit(); nGit = userDataGit.NGit; nGit.commits().assert_Size_Is(2, "there should be two commits here"); UserGroup.None.assert(); }
//Helper methods public void SetUpNGit() { TmRest.TBot_Run("Git"); // trigger unpack of NGit and Sharpen dlls var fluentSharpGit = new API_NGit(); Assert.NotNull(fluentSharpGit, "fluentSharpGit was null"); }
public Test_API_NGit() { NGitApi = new API_NGit(); }
public static List<string> commit_Files(this RevCommit revCommit, API_NGit nGit) { var repoFiles = new List<string>(); revCommit.commit_TreeWalk(nGit, treeWalk => repoFiles.Add(treeWalk.PathString)); return repoFiles; }
public static List<string> commit_Files_FullPath(this RevCommit revCommit, API_NGit nGit) { return (from file in revCommit.commit_Files(nGit) select nGit.file_FullPath(file)).toList(); }
private GitData_Repository getGitData(API_NGit nGit, bool clearCache) { if (clearCache) "gitData".o2Cache(null); return "gitData".o2Cache(()=> { var gitData = nGit.gitData_Repository(); gitData.map_File_Commits(); return gitData; }); }
public static RevCommit commit_TreeWalk(this RevCommit revCommit, API_NGit nGit, Action<TreeWalk> onNext) { var treeWalk = new TreeWalk(nGit.Repository); var tree = revCommit.Tree; treeWalk.AddTree(tree); treeWalk.Recursive = true; while (treeWalk.Next()) onNext(treeWalk); return revCommit; }
public static List<GitData_File> gitData_Files(this RevCommit revCommit, API_NGit nGit) { var gitData_Files = new List<GitData_File>(); revCommit.commit_TreeWalk(nGit, treeWalk => gitData_Files.add_File(treeWalk)); return gitData_Files; }
public void open() { //git_Open(); // already triggers methods funcionality //test Exception handing var nGit = new API_NGit(); Assert.IsNull(nGit.open(null)); Assert.IsInstanceOf<ArgumentNullException>(nGit.Last_Exception); }
public void init() { //git_Init(); // already triggers methods funcionality //test Exception handing (by creating a .git file (which should be a folder)) var tempDir = "tempDir".tempDir(); var fakeGitFolder = tempDir.pathCombine(".git"); Assert.IsTrue(tempDir.dirExists()); Assert.IsFalse(tempDir.isGitRepository()); "aaa".saveAs(fakeGitFolder); // Assert.IsFalse(tempDir.isGitRepository()); var nGit = new API_NGit(); var result = nGit.init(tempDir); Assert.IsFalse(tempDir.isGitRepository()); Assert.IsNull(result); Assert.IsInstanceOf<JGitInternalException>(nGit.Last_Exception); tempDir.delete_Folder(); Assert.IsFalse(tempDir.dirExists()); }
public void setUp() { //create repos repoPath1 = "repo1".tempDir(); repoPath2 = "repo2".tempDir(); nGit1 = repoPath1.git_Init(); nGit2 = repoPath2.git_Init(); Assert.AreNotEqual(repoPath1, repoPath2); Assert.IsTrue (repoPath1.isGitRepository()); Assert.IsTrue (repoPath2.isGitRepository()); //add a file to repo 1 revCommit1 = nGit1.add_and_Commit_Random_File(); }
public void setUp() { //create temp repo with no Admin user userData = new TM_UserData(true) { Path_UserData = "nonGitRepo".tempDir() }; userData .SetUp(); nGit = userData.NGit; Assert.AreEqual(2, nGit.commits().size() , "there should be two commits here"); }
public static List<GitData_File_Commit_Full> file_Commits(this string fileToMap, API_NGit nGit) { var file_Commits = new List<GitData_File_Commit_Full>(); var mappedSha1 = new List<string>(); var gitRepository = nGit.gitData_Repository(false); gitRepository.Config.Load_CommitTrees = true; gitRepository.loadData(); var results = new List<string>(); foreach(var commit in gitRepository.Commits) foreach(var file in commit.Tree) { if (file.FilePath == fileToMap) if (mappedSha1.contains(file.Sha1).isFalse()) { var fileCommit = new GitData_File_Commit_Full { FilePath = fileToMap, Sha1 = file.Sha1, CommitId = commit.Sha1, Author = commit.Author, Committer = commit.Committer, When = commit.When, FileContents = nGit.open_Object(file.Sha1).bytes().ascii() }; file_Commits.Add(fileCommit); mappedSha1.add(file.Sha1); } } return file_Commits; }
public static Dictionary<string, string> commit_Files_IndexedBy_SHA1(this RevCommit revCommit, API_NGit nGit) { var repoFiles = new Dictionary<string,string>(); revCommit.commit_TreeWalk(nGit, treeWalk => { var objectId = treeWalk.GetObjectId(0); repoFiles.Add(objectId.Name, treeWalk.PathString); }); return repoFiles; }