Stash - which plugin module is used for commit history

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

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

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.

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!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

31,342 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you