Examples of GistFile


Examples of org.eclipse.egit.github.core.GistFile

    filename = new String[theSketches.length];
    int indexOfUsername=-1;
    boolean makePrivate=false;
   
    for(int j =0; j<theSketches.length; j++){
      file[j]=new GistFile();
      if(theSketches[j]==editor.getSketch().getCurrentCode()){//so you don't need to save
        theSketchesContent[j]=editor.getText();
      }else{
        theSketchesContent[j]=theSketches[j].getProgram();
      }
          if(theSketches[j].getExtension()=="ino" || theSketches[j].getExtension()=="pde"){
            indexOfUsername=theSketchesContent[j].indexOf("USE_GITHUB_USERNAME=");
            makePrivate=theSketchesContent[j].contains("MAKE_PRIVATE_ON_GITHUB");
           
            if(indexOfUsername!=-1){//if the user specifies a username in the code comments
            username=theSketchesContent[j].substring(indexOfUsername+20);
              username=username.substring(0,username.indexOf('\n')).trim();
              if(table.containsKey(username)){
                password=(String) table.get(username);
              }else{
                System.out.println("No entry found for specified username in gistCredentials.txt, check spelling and try again");
                return;
              }
          }else{ //defaults to first entry in gistCredentials.txt
              username=table.keySet().toArray()[0].toString(); //first entry
              password=(String) table.get(table.keySet().toArray()[0]);
          }
          }
    }
   
    System.out.println("Sending source to "+username+"'s github account...");
 
    client = new GitHubClient().setCredentials(username, password);
    service = new GistService(client);
     
    try{
        List<Gist> gists = service.getGists(username);
        Boolean foundMatchingGist=false;
        for (int i = gists.size(); --i >= 0;){  //backwards so the first one found is the oldest one
          gist = (Gist)gists.get(i);
         
          if(gist.getDescription().toUpperCase().contains(serialNumber.toUpperCase())){ //found the last matching gist. toUpperCase is because Windows capitalizes the letters I hope this isn't a problem!
                if(foundMatchingGist==true){ //if one has already been found then an extra was made in error and needs to be cleaned up
                  //delete the spurious gist
                  service.deleteGist(gist.getId());
                }else if(gist.isPublic()==!makePrivate){// rewrite the gist if there is already one and the privacy settings are the same
                  for (String key : gist.getFiles().keySet()) {// "delete" old ones, if this wasn't here every time you saved a sketch with a new name it would not overwrite the old sketch
                    boolean matchingFile=false;
                    for(int j =0; j<theSketches.length; j++){
                      if((theSketches[j].getPrettyName()+"."+theSketches[j].getExtension()).contains(gist.getFiles().get(key).getFilename())){
                        matchingFile=true;
                      }
                    }
                    if(!matchingFile){
                    service.updateGist(gist.setFiles(Collections.singletonMap(key, new GistFile())));//this makes a blank sketch show in the revisions but it's the best solution I found
                    }
                }
                  for(int j =0; j<theSketches.length; j++){
                  file[j].setContent(theSketchesContent[j]);
                    filename[j] = theSketches[j].getPrettyName()+"."+theSketches[j].getExtension();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.