當前位置: 首頁>>代碼示例>>Java>>正文


Java GitHub.connectUsingPassword方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GitHub.connectUsingPassword方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.connectUsingPassword方法的具體用法?Java GitHub.connectUsingPassword怎麽用?Java GitHub.connectUsingPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GitHub的用法示例。


在下文中一共展示了GitHub.connectUsingPassword方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeRepo

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public synchronized static void removeRepo(String owner, String repoName) throws KaramelException {

    try {
      GitHub gitHub = GitHub.connectUsingPassword(GithubApi.getUser(), GithubApi.getPassword());
      if (!gitHub.isCredentialValid()) {
        throw new KaramelException("Invalid GitHub credentials");
      }
      GHRepository repo = null;
      if (owner.compareToIgnoreCase(GithubApi.getUser()) != 0) {
        GHOrganization org = gitHub.getOrganization(owner);
        repo = org.getRepository(repoName);
      } else {
        repo = gitHub.getRepository(owner + "/" + repoName);
      }
      repo.delete();

    } catch (IOException ex) {
      throw new KaramelException("Problem authenticating with gihub-api when trying to remove a repository");
    }
  }
 
開發者ID:karamelchef,項目名稱:karamel,代碼行數:21,代碼來源:GithubApi.java

示例2: createGitHubClient

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
GitHub createGitHubClient(String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception {
    GitHub github = null;
    if (usernameAndPasswordIsAvailable(usernameToUse, passwordToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectToEnterprise(endPointToUse, usernameToUse, passwordToUse);
        } else {
            github = GitHub.connectUsingPassword(usernameToUse, passwordToUse);
        }
    }
    if (oAuthTokenIsAvailable(oauthAccessTokenToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectUsingOAuth(endPointToUse, oauthAccessTokenToUse);
        } else {
            github = GitHub.connectUsingOAuth(oauthAccessTokenToUse);
        }
    }
    if (github == null) {
        github = GitHub.connect();
    }
    return github;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-build-status-notifier,代碼行數:22,代碼來源:GitHubProvider.java

示例3: commit

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void commit(String rep,String content,String commitmsg,String path,boolean isAdd){
	try{
	GitHub github = GitHub.connectUsingPassword("[email protected]", "xiaomin0322#####");
	GHRepository repo =github.getRepository(rep);
	
	GHContent contentObj = null;
	if(isAdd){
		List<GHContent> contents = repo.getDirectoryContent("/");
		if(CollectionUtils.isNotEmpty(contents)){
			for(GHContent c:contents){
				String name = c.getName();
				System.out.println("name==="+name);
				if(path.equals(name)){
					System.out.println("找到目標文件");
					contentObj = c;
				}
			}
		}
	}
	if(contentObj==null){
		System.out.println("創建文件>>>>>>>>>>>>>>>>>>>>>");
		repo.createContent(content,commitmsg, path);
		//contentObj = repo.getFileContent(path);
	}
	if(isAdd){
          StringBuilder builder = new StringBuilder();
		String str = IOUtils.toString(contentObj.read());
		System.out.println("獲取遠程內容為:"+str);
		builder.append(str).append("\r\n");
		builder.append(content);
		contentObj.update(builder.toString(), commitmsg);
	}
	
	System.out.println("提交成功>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
	}catch(Exception e){
		System.out.println("提交出現異常>>>>>>>>>>>>>>>>>>>>>>>>>");
		e.printStackTrace();
	}
	
}
 
開發者ID:xiaomin0322,項目名稱:alimama,代碼行數:41,代碼來源:GitHubUtils.java

示例4: connectToPublicGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub connectToPublicGitHub(GithubPluginSettings pluginSettings) throws IOException {
    if (pluginSettings.containsUsernameAndPassword()) {
        LOGGER.debug("Create GitHub connection to public GitHub using username and password");
        return GitHub.connectUsingPassword(pluginSettings.getUsername(), pluginSettings.getPassword());
    } else if (pluginSettings.containsOAuthToken()) {
        LOGGER.debug("Create GitHub connection to public GitHub with token");
        return GitHub.connectUsingOAuth(pluginSettings.getOauthToken());
    }
    return null;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-oauth-login,代碼行數:11,代碼來源:GitHubProvider.java

示例5: prepare

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@BeforeClass
public void prepare() throws Exception {
  gitHub = GitHub.connectUsingPassword(gitHubUsername, gitHubPassword);
  gitHubRepository = gitHub.createRepository(REPO_NAME).create();
  String commitMess = String.format("new_content_was_added %s ", System.currentTimeMillis());
  testUserPreferencesServiceClient.addGitCommitter(gitHubUsername, productUser.getEmail());
  Path entryPath = Paths.get(getClass().getResource("/projects/git-pull-test").getPath());
  gitHubClientService.addContentToRepository(entryPath, commitMess, gitHubRepository);
  ide.open(ws);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:11,代碼來源:GitPullTest.java

示例6: onEnable

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public void onEnable() {
    saveDefaultConfig();
    ConfigurationSerialization.registerClass(KitImpl.class);
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimeSlowRunnable(this), 100L, 100L);
    registerListeners(new PlayerJoinListener(this), new PlayerQuitListener(this), new PlayerTeleportListener(this),
            new PlayerItemConsumeListener(this),
            new WarpSignChangeListener(this), new WarpPlayerInteractListener(this));
    registerCommands();
    warpManager = new WarpManager(this);
    kitManager = new KitManager(this);
    drinkManager = new DrinkManager(this);
    try {
        File gitHubFile = new File(getDataFolder(), "github.yml");
        if (gitHubFile.exists()) {
            YamlConfiguration gitHubConfig = new YamlConfiguration();
            gitHubConfig.load(gitHubFile);
            if (gitHubConfig.getString("oauth") != null) {
                getLogger().info("Found OAuth token in GitHub config, attempting to connect using OAuth...");
                gitHub = GitHub.connectUsingOAuth(gitHubConfig.getString("oauth"));
            } else if (gitHubConfig.getString("user") != null && gitHubConfig.getString("password") != null) {
                getLogger().info("Found user and password in GitHub config, attempting to connect using user and password...");
                gitHub = GitHub.connectUsingPassword(gitHubConfig.getString("user"), gitHubConfig.getString("password"));
            } else {
                getLogger().info("No user & password or OAuth token found in GitHub config, attempting to connect anonymously...");
                gitHub = GitHub.connectAnonymously();
            }
        } else {
            getLogger().info("No GitHub config found, attempting to connect anonymously...");
            gitHub = GitHub.connectAnonymously();
        }
    } catch (IOException | InvalidConfigurationException exception) {
        exception.printStackTrace();
    }
    drinkManager.setupRecipes();
    logMessagesEnabledFile = new File(getDataFolder(), "log-messages-enabled.yml");
}
 
開發者ID:WaywardRealms,項目名稱:Wayward,代碼行數:38,代碼來源:WaywardEssentials.java

示例7: testCreate

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void testCreate()throws Exception{
	GitHub github = GitHub.connectUsingPassword("[email protected]", "xiaomin0322####");
	GHCreateRepositoryBuilder repo = github.createRepository("testgithub");
	repo.create();
}
 
開發者ID:xiaomin0322,項目名稱:alimama,代碼行數:6,代碼來源:GitHubUtils.java

示例8: submitBugReport

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void submitBugReport(String message) {
		JPanel reportBugPanel = new JPanel(new GridLayout(4,1));
		JLabel typeLabel = new JLabel("Type of Report:");
		JComboBox reportType = new JComboBox(Utility.bugReportTypes);
		
		if (!message.equals("")) {
			typeLabel.setEnabled(false);
			reportType.setEnabled(false);
		}
		
		JPanel typePanel = new JPanel(new GridLayout(1,2));
		typePanel.add(typeLabel);
		typePanel.add(reportType);
		JLabel emailLabel = new JLabel("Email address:");
		JTextField emailAddr = new JTextField(30);
		JPanel emailPanel = new JPanel(new GridLayout(1,2));
		emailPanel.add(emailLabel);
		emailPanel.add(emailAddr);
		JLabel bugSubjectLabel = new JLabel("Brief Description:");
		JTextField bugSubject = new JTextField(30);
		JPanel bugSubjectPanel = new JPanel(new GridLayout(1,2));
		bugSubjectPanel.add(bugSubjectLabel);
		bugSubjectPanel.add(bugSubject);
		JLabel bugDetailLabel = new JLabel("Detailed Description:");
		JTextArea bugDetail = new JTextArea(5,30);
		bugDetail.setLineWrap(true);
		bugDetail.setWrapStyleWord(true);
		JScrollPane scroll = new JScrollPane();
		scroll.setMinimumSize(new Dimension(100, 100));
		scroll.setPreferredSize(new Dimension(100, 100));
		scroll.setViewportView(bugDetail);
		JPanel bugDetailPanel = new JPanel(new GridLayout(1,2));
		bugDetailPanel.add(bugDetailLabel);
		bugDetailPanel.add(scroll);
		reportBugPanel.add(typePanel);
		reportBugPanel.add(emailPanel);
		reportBugPanel.add(bugSubjectPanel);
		reportBugPanel.add(bugDetailPanel);
		Object[] options = { "Send", "Cancel" };
		
		int value = JOptionPane.showOptionDialog(Gui.frame, reportBugPanel, "Bug Report",
				JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
		
		if (value == 0) {
			try {
				GitHub github = GitHub.connectUsingPassword("buggsley", "ibiosim3280");
				GHRepository iBioSimRepository = github.getRepository("MyersResearchGroup/iBioSim");
				GHIssueBuilder issue = iBioSimRepository.createIssue(bugSubject.getText().trim());
				issue.body(System.getProperty("software.running") + "\n\nOperating system: " + 
						System.getProperty("os.name") + "\n\nBug reported by: " + emailAddr.getText().trim() + 
						"\n\nDescription:\n"+bugDetail.getText().trim()+message);
				issue.label(reportType.getSelectedItem().toString());
				issue.create();
			} catch (IOException e) {
				JOptionPane.showMessageDialog(Gui.frame, "Bug report failed, please submit manually.",
						"Bug Report Failed", JOptionPane.ERROR_MESSAGE);
				Preferences biosimrc = Preferences.userRoot();
				String command = biosimrc.get("biosim.general.browser", "");
				command = command + " http://www.github.com/MyersResearchGroup/iBioSim/issues";
				Runtime exec = Runtime.getRuntime();
				
				try
				{
					exec.exec(command);
				}
				catch (IOException e1)
				{
					JOptionPane.showMessageDialog(Gui.frame, "Unable to open bug database.", "Error", JOptionPane.ERROR_MESSAGE);
				}
			}
		}
		
//		JOptionPane.showMessageDialog(Gui.frame, "Please verify that your bug report is in the incoming folder.\n" +
//				"If not, please submit your bug report manually using the web interface.\n", 
//				"Bug Report", JOptionPane.ERROR_MESSAGE);
//		submitBugReportTemp(message);
	}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:78,代碼來源:Utility.java

示例9: main

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void main(String[] args) {
    mainID = Thread.currentThread().getId();

    log("Loading commands from " + Commands.class.getCanonicalName() + "..");
    commands = CommandHolder.lazyLoadCommands(Commands.class);

    log("Reading from passsword file..");
    try {
        String text = FileUtils.readAllLines("data/github.dat")[0];

        username = text.split(":")[0];
        password = text.split(":")[1];

        log("Loading cache data..");
        loadAnnounced();

        log("Logging into github..");
        GitHub github = GitHub.connectUsingPassword(username, password);
        log("Getting repo..");
        OpenMC = github.getRepository("GamezGalaxy2/OpenMC");

        log("Reading .pullignore file..");
        pullIgnores = FileUtils.readToList("data/.pullignore");

        log("Staritng server in separate process..");
        startServer();

    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    log("Starting main loop!");
    looper = new Thread(MAIN_LOOP);
    looper.start();
    final Scanner scan = new Scanner(System.in);
    while (!end) {
        String line = scan.nextLine();
        char cmd = line.toCharArray()[0];
        line = line.substring(1).trim();
        for (CommandHolder c : commands) {
            if (c.matches(cmd)) {
                c.invoke(line);
            }
        }
    }
}
 
開發者ID:cannodan000,項目名稱:OpenMC,代碼行數:48,代碼來源:Main.java

示例10: saveIssues

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void saveIssues(String repoDetails) throws IOException {
	String user;
	String password;

	try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
		System.out.println("user:");
		user = br.readLine();
		System.out.println("password:");
		password = br.readLine();
	}

	String[] repoInfo = repoDetails.split("/");
	GitHub github = GitHub.connectUsingPassword(user, password);
	GHRepository repository = github.getUser(repoInfo[0]).getRepository(repoInfo[1]);
	List<String> columns = Arrays.asList("Id", "Title", "Creator", "Assignee", "Milestone", "Label", "Created",
			"Closed", "State");

	try (BufferedWriter writer = Files.newBufferedWriter(new File("issues.csv").toPath(), StandardCharsets.UTF_8)) {
		int index = 1;

		writer.append(Joiner.on("\t").join(columns) + "\n");

		for (GHIssue issue : Iterables.concat(repository.listIssues(GHIssueState.OPEN),
				repository.listIssues(GHIssueState.CLOSED))) {
			List<String> parts = new ArrayList<>();

			parts.add(String.valueOf(issue.getNumber()));
			parts.add(issue.getTitle());
			parts.add(issue.getUser().getLogin());

			parts.add(issue.getAssignee() != null ? issue.getAssignee().getLogin() : "");
			parts.add(issue.getMilestone() != null ? issue.getMilestone().getTitle() : "");

			// Add labels
			parts.add(issue.getLabels().stream().map(GHLabel::getName).collect(Collectors.joining("+")));

			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			parts.add(issue.getCreatedAt() != null ? sdf.format(issue.getCreatedAt()) : "");
			parts.add(issue.getClosedAt() != null ? sdf.format(issue.getClosedAt()) : "");

			parts.add(issue.getState().toString());

			String cleanedParts = parts.stream().map(s -> s.replace("\t", " ").replace("\n", " "))
					.collect(Collectors.joining("\t"));

			writer.write(cleanedParts + "\n");
			System.out.println(index++ + "\tissues processed");
		}
	}
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:51,代碼來源:IssuesDownload.java


注:本文中的org.kohsuke.github.GitHub.connectUsingPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。