用户如何使用gitlab4j-api从受保护的分支(从我的Org。Git存储库)获取最新副本?

时间:2018-08-20 10:53:20

标签: java gitlab gitlab-api

我正在尝试通过本地组织git存储库连接Java程序,并且正在使用gitlab4j-api开源API,我能够从基本Java程序登录并获取项目详细信息。但是,哪种方法可以帮助我进行结帐(个人用户可以从其分支机构获取最新副本)过程? 谢谢

package git4j.git4j;
import java.util.ArrayList;
import java.util.List;

import org.gitlab4j.api.CommitsApi;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.ProjectApi;
import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CommitAction;

import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.CommitAction.Action;
import org.gitlab4j.api.models.CommitAction.Encoding;


public class App 
{
@SuppressWarnings("deprecation")
    public static void main( String[] args )throws GitLabApiException
    {
      GitLabApi api = GitLabApi.login("http://organizationt_git.ad.com/", "username", "password");

    ProjectApi projApi=api.getProjectApi();
    Project p = projApi.getProject(project_id);

    System.out.println("project rendered is"+p.getName());
    List <Project> pList=projApi.getProjects("project_name");

           for(Project p:pList){                        

                                           System.out.println(p.getName());
                           }

                           CommitAction ca= new CommitAction();
                           Action a = Action.UPDATE;
                           ca.setAction(a); 
                           ca.setFilePath("c/");
                           ca.setPreviousPath("c/");
                           ca.setContent("test content");
                           ca.setEncoding(Encoding.TEXT);
                           ca.setLastCommitId("");
                           List<CommitAction> caList = new 
                           ArrayList<CommitAction>();
                           caList.add(ca);
                           CommitsApi cApi=api.getCommitsApi();
                           Commit c = cApi.createCommit(project_id,"branch", "commit message", "branch_refer_to", "", "username", caList);
   }
}

0 个答案:

没有答案