palantir / stash-codesearch-plugin

Provides global repository, commit, and file content search for Atlassian Stash instances
Apache License 2.0
62 stars 20 forks source link

filter forks from search results? #14

Closed memory closed 3 years ago

memory commented 9 years ago

As an advanced search option, would it be possible to filter search results only to repositories that are, from stash's POV, the origin for a set of clones? (In most cases this would be from repos that live under a project rather than a user, but really the defining feature would be the lack of an "origin" key in the repo metadata.)

terabyte commented 8 years ago

Hmm, good idea - I'd have to investigate what the APIs support to determine if a repo is a fork of another repo, and we'd have to figure out what the UI for that would look like. (auto-complete dropdown? Support multiple repos, or just one?) Seems like a pretty big feature, but if you wanted to implement it I'd be glad to have it.

memory commented 8 years ago

I have good news and bad news. :)

The good news is that I think this would actually be pretty easy to do by iterating over the projects API and filtering out anything with a key that begins with ~.

The bad news is... boy howdy am I not in any way a fluent java developer, so I am probably not the person you want writing this code. :(

(I'll see if I can find someone here who I can con into doing this, but no promises...)

terabyte commented 8 years ago

@memory - that is so awesome, good luck in your search! I would be glad to make myself available to answer questions and help out - you can find me as 'cmyers' on irc.freenode.net or via 'cmyers@pernixdata.com' on google talk, and I answer those pretty much whenever I am at my desk.

terabyte commented 8 years ago

@memory - oh, one more thing - people can create repos in their private areas (~username) that are not forks. It is unclear if there might be a programmatic way to make forks that are not in ~username also (say, create a fork then move it?).

Fortunately, there is a call on the Repository object getOrigin() that returns the parent repo (and I guess null if it is not a fork?) https://developer.atlassian.com/static/javadoc/stash/0.9.9/reference/com/atlassian/stash/repository/Repository.html#getOrigin%28%29

So that is probably the way to go.