Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratharmasanthiran2018-04-04 08:00:53 +0000
committeratharmasanthiran2018-04-04 08:00:53 +0000
commit4adb3d178a5b32b922480ed922ddaffc1d4d4aa3 (patch)
treed260bc0f9ddd8550a371cf1011191b60afca77ad
parent4c6677131d7bb6fb70781bb2d5a37d03b3da2a18 (diff)
downloadorg.eclipse.ease.scripts-4adb3d178a5b32b922480ed922ddaffc1d4d4aa3.tar.gz
org.eclipse.ease.scripts-4adb3d178a5b32b922480ed922ddaffc1d4d4aa3.tar.xz
org.eclipse.ease.scripts-4adb3d178a5b32b922480ed922ddaffc1d4d4aa3.zip
Bug 532956: Added an example to show complete git workflow.
This example shows how to use the methods in the Git module in order to automatically clone a remote repository, importing it into the workspace, adding a sample text file and then finally add, commit and push back to the remote repository. Task-Url:https://bugs.eclipse.org/bugs/show_bug.cgi?id=532956 Change-Id: I2b1de182804bc807153a2b219f607078306f1fed Signed-off-by: atharmasanthiran <aathmant.16@cse.mrt.ac.lk>
-rw-r--r--Git Example Script/.project11
-rw-r--r--Git Example Script/example.js36
2 files changed, 47 insertions, 0 deletions
diff --git a/Git Example Script/.project b/Git Example Script/.project
new file mode 100644
index 0000000..6035e77
--- /dev/null
+++ b/Git Example Script/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Git Example Script</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/Git Example Script/example.js b/Git Example Script/example.js
new file mode 100644
index 0000000..460c2b7
--- /dev/null
+++ b/Git Example Script/example.js
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Aathman Tharmasanthiran and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Aathman Tharmasanthiran - initial API and implementation
+ ******************************************************************************/
+
+loadModule('/System/Git');
+loadModule('/System/Resources');
+
+var localRepo = "C:/New folder";
+var remoteRepo = "https://github.com/AathmanT/Example-codes.git";
+var username = "";
+var password = "";
+
+var gitRepo = clone(remoteRepo, localRepo, username, password);
+
+var projectFileLocations = findFiles("*.project", localRepo, true);
+
+for (var i = 0; i < (projectFileLocations.length); i++) {
+
+ linkProject((projectFileLocations[i]).getParent());
+}
+
+var fileHandle = writeFile(localRepo + "/Test file.txt",
+ "This is the test file added to test commit.");
+
+fileHandle.close();
+
+add(localRepo, "Test file.txt");
+
+commit(localRepo, "Added a test file", "AathmanT aathmant@gmail.com");
+
+push(localRepo);

Back to the top