Stash - which plugin module is used for commit history

Vincent September 24, 2015

I am still new to Stash, I want to create a plugin to view commit history and the info of each file that stored on repository,  can anyone tell me which plugin module is best to get start? I used repository hook module before, but it seems like i can't get info of the file with it.

 

thanks in advance!

3 answers

1 accepted

0 votes
Answer accepted
tinyCabbage September 29, 2015

So the code below should give you a list of all the repositories in stash, and for each repository download it and run the git log command to get a list of all the commits. 

 

 

public static void main(String[] args) throws MalformedURLException  {
        HttpClientConfig clientConfig = new HttpClientConfig(new URL(url), user, pwd);
        HttpClientStashClientFactory factory = new HttpClientStashClientFactoryImpl();
        if (factory.getStashClient(clientConfig).getAccessibleProjects(0, 10) != null)
        	factory.getStashClient(clientConfig).getAccessibleProjects(0, 10).getValues().forEach((Project project) -> 
				factory.getStashClient(clientConfig).getRepositories(project.getKey(), null, 0, 0).getValues().forEach((Repository repo) -> 

/*

			Now that you have the url, down each repository, and run 


			 "git --no-pager log --oneline"
 			Parse the result into something and go through the data. 
*/
		);
    }

Saying that, there might actually be a class that deals with the commit history in the Atlassian API - this I am not sure of, but the above solution also works (might take a while to do the first run)

If this helps, can I get a upvote, trying to get 3 points so I don't have the 1msg per 24hour limitation

0 votes
Vincent September 26, 2015

thanks Peter, do you mean that using the classes in com.stash.scm.git? I had tried it, but i couldnt import the all .jar in com.stash.scm.git, I am using maven to import the all .jar of stash (adding maven repository and dependencies to pom.xml).

could you tell me what other classes I can used in my plugin to call git commands? thanks!

0 votes
tinyCabbage September 24, 2015

all the commit history stuff is held in the git repository itself. 

 

To get it, have your plugin call "git --no-pager log --oneline" and parse the results however you want.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events