Version Control
Making backups and carefully creating a repository that maintains version control is a good thing. This Knowledge Base article will show you how to set that up.
Git Repository
Because SIL code is stored in text files, it is totally possible to create a git repository directly in the silprograms folder. Once the repository has been set up, use the SIL code below to make commits from the SIL Gadget Runner. See this Atlassian documentation on creating a git repository.
persistent string gitPath;
Â
string baseCommand =Â "git --git-dir=\""Â + gitPath +Â "\\.git\" --work-tree=\""Â + gitPath +Â "\" ";
Â
string [] folders = gadget_getMultiValues(argv, "Folders");
string [] files = gadget_getMultiValues(argv, "Files");
string commitMessage = arrayGetElement(argv, "Commit Message");
Â
for(string f in folders) {
    string command = baseCommand + "add --all \"" + gitPath + "\\" + f + "\"";
    runnerLog("Running git command: " + command);
    runnerLog(system(command));Â
}
Â
for(string f in files) {
    string command = baseCommand + "add \"" + gitPath + "\\" + f + "\"";
    runnerLog("Running git command: " + command);
    runnerLog(system(command));Â
}
Â
string command = baseCommand +Â "commit -a -m \""Â + commitMessage +Â "\"";
runnerLog("Running git command: "Â + command);
runnerLog(system(command));
command = (baseCommand +Â "push origin \nusername: jmuse \n ");
runnerLog("Running git command: "Â + command);
runnerLog(system(command));
Params Script:
Â
persistent string gitPath =Â "C:\\Program Files\\Atlassian\\Application Data\\JIRA_versions\\silprograms";
Â
function getFiles(string dir) {
    Â
    string [] dirs = findDirectories(dir, ".*");
    string [] silFiles;
    string [] files;
    Â
    for(string dir in dirs) {
        if(contains(dir, ".git") == false) {
            silFiles += findFiles(dir, ".*");
        }
    }
    Â
    silFiles = arraySort(silFiles, false);
    Â
    for(string b in silFiles) {
        string temp = replace(b, dir, "");
        temp = replace(temp, "/", "");
        temp = substring(temp, 1, length(temp));
        files += temp;
    }
    Â
    return arraySort(files, false);
}
Â
function getFolders(string dir) {
    Â
    string [] folders = findDirectories(dir, ".*");
    string [] subFolders;
    string [] folderNames;
    Â
    for(string f in folders) {
        if(contains(f, ".git") == false) {
            folderNames += substring(replace(f, dir, ""), 1, length(dir));
            string [] subfold = findDirectories(f, ".*");
            for(string sf in subfold) {
                folderNames += substring(replace(sf, dir, ""), 1, length(dir));
            }
            Â
        }
    }
    Â
    folderNames += folderNames;
    return arraySort(arrayToSet(folderNames), false);
} |
Â
Code for SIL Runner Gadget
gadget_createMultiSelectList("Folders", getFolders(gitPath), "", false, "");
gadget_createMultiSelectList("Files", getFiles(gitPath), "", false, "");
gadget_createTextArea("Commit Message", "", 10, true, ""); |
Related articles
Filter by label
There are no items with the selected labels at this time.