Skip to content

allow allow contribute a search filter in jira bridge - #505

Closed
nxmatic wants to merge 6 commits into
git-bug:masterfrom
nxmatic:master
Closed

nxmatic wants to merge 6 commits into
git-bug:masterfrom
nxmatic:master

Conversation

@nxmatic

@nxmatic nxmatic commented Nov 28, 2020

Copy link
Copy Markdown

Hi

I needed to select JIRA issues with more constraints (working on old projects with monilitic projects. In the meanwhile I've discovered other problems, which are also fixed in the branch. I've checked on my side that the existing tests are still passing.
I didn't took the time for contributing new tests covering the feature.

  • jira filtering
  • allow bridge contribution in global settings (as a work-around about anti-slash erased in import timestamp saving)
  • fixed import timestamp loading
  • fixed errors on identities about whitespace not trimmed

I hope you'll agree to merge the jira filtering feature in the trunk. Thank you for your work, git-bug is a really amazing product.

@MichaelMure MichaelMure left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for looking into that. The Jira bridge definitely need some love.
As you'll see in my review, there is a few thing you can't do. I also have a bunch of questions.

Regarding the filtering, the last time it was discussed I was hoping to use the query language to allow the user to define what they want to import. At the moment this language is only used to query bugs with ls but it could be a great fit. What do you think?

The query package implement a lexer/parser for that language that produce a generic description of a query/filter. I was thinking that bridges could accept such a user-defined query. The bridge when importing could (if possible) translate those filter into native bugtracker specific query. When something is not or can't be supported, the filtering would happen on the Bug after being imported but before writing on disk.

Comment thread bridge/jira/jira.go Outdated
Comment thread repository/gogit.go
// see: https://github.com/go-git/go-git
// see: https://github.com/src-d/go-git/issues/760
return newGoGitGlobalConfig(repo.r)
return newGitConfig(gitCli{path: repo.path}, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain this change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI-based git repo is planned to be removed.

@nxmatic nxmatic Nov 29, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug in the marshalling which is deleting the anti-slashes from the values. I've replaced with the git cli implementation. This should be solved in the go library. Didn't reported yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug in the marshalling which is deleting the anti-slashes from the values. I've replaced with the git cli implementation. This should be solved in the go library. Didn't reported yet.

Please report it, it could cause many problems.

Comment thread bridge/jira/jira.go
metaKeyJiraKey = "jira-key"
metaKeyJiraUser = "jira-user"
metaKeyJiraProject = "jira-project"
metaKeyJiraBridge = "jira-bridge"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change, it's going to break the import of people already using that bridge.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, I've planned to use the bridge as the selector. ie: the bridge that import should do the export. I think it's a more strict this way. This is because I'm replacing the project constraint with the filter if defined.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a back-ward mechanism, will preserve the project meta key and use it if there is no jira bridge key defined. The jira bridge meta key will be only used when the user will have provided a filter overriding the project filter.

Comment thread bridge/core/bridge.go
keyPrefix := fmt.Sprintf("git-bug.bridge.%s.", name)

pairs, err := repo.LocalConfig().ReadAll(keyPrefix)
pairs, err := repo.AnyConfig().ReadAll(keyPrefix)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you need to read the global config? The bridge config only make sense and is stored locally.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sharing bridges definition in multiple projects. This way I can define them only once for the multiple repositories we're working on in the same jira project.

Comment thread bridge/core/interfaces.go

type Importer interface {
Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
Init(ctx context.Context, repo *cache.RepoCache, name string, conf Configuration) error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you would need to pass the bridge name. This name is purely arbitrary for the user to identify configured bridges, so it's not valuable for anything else. Am I missing something?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For replacing the project id, will be used for the export filtering in the bridge. I missed that change, will update the pull request with.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about sharing the bridges configuration in the repository itself. All the contributors are using the same no ? This way when a contributor clone the repository, he'll get the associated bridges with. He will only have to give his credentials.

@nxmatic

nxmatic commented Nov 29, 2020

Copy link
Copy Markdown
Author

I've reviewed the other pull requests and I think #241 is addressing the same. I'm not sure about the query translator, because we want to filter issues which do not share the same model. I think it's better to let the user define it in the native language.

For now, the bridge is synching in only what I wanted, and synching out only the bugs I've worked on. So I'm fine with that for now.

Another big thank for your work. I really enjoy using the product.

@nxmatic
nxmatic force-pushed the master branch 2 times, most recently from ef96536 to 9dfef20 Compare November 29, 2020 23:13
@MichaelMure

MichaelMure commented Nov 29, 2020 •

Copy link
Copy Markdown
Contributor

For sharing bridges definition in multiple projects. This way I can define them only once for the multiple repositories we're working on in the same jira project.

It seems to me that a lot of your changes are related to this. Unfortunately that's not something I'm willing to merge but let me try to explain why.

The complex and annoying part when configuring a bridge is the authentication part: generating an API token with the correct access, recording a password ... It's both complex code-wise, error prone and simply annoying for the user. BUT, once this is done for a bugtracker, this credential is shared across repositories.

What's left when setting up a new bridge in another repo is defining 1) the type of bridge, 2) the URL, 3) the login, and then 4) you can reuse the credential. When done right this can be a matter of seconds.

I'm saying "when done right" because the Jira bridge is not as smart as it could. If you try the Github bridge, you will see that it auto-detect the correct project on Github from the git remotes. The Jira bridge could do something similar, leading to a really efficient process.

The way the Jira bridge is designed, a local git repo is mapped to a Project in Jira. Is that assumption accurate? If so, you can just have one bridge defined per repo. It's simple and understandable.

On the other hand, if you have bridges shared globally on the machine, you break many assumptions on how bridges works. I'm sure you have seen some of those breakage when going that way. What does it means when you pull the Jira bugs in one repo, then do that again in another repo ? What about the "last import time" which allows you to not download everything each time you pull?

Edit: in short, you are a bit going against the grain on the bridges design. This design came up after a number of (painful) iteration so I would need a good reason to change things. It seems to me that there is a simpler and better way: make the configurator smarter.

@MichaelMure

Copy link
Copy Markdown
Contributor

I'm not sure about the query translator, because we want to filter issues which do not share the same model. I think it's better to let the user define it in the native language.

I'm not so sure about that. Here is my reasoning:

  • using a bugtracker "native" language to define a filtering means either 1) some form of API native filtering or 2) the native query language
    1. the API filtering is probably a no-go, most likely complex and unbearable for the average user.
    2. the native query language could work, but then you have a different language for each bridge
  • git-bug is a sort of lingua franca itself. The native concepts (bug, comment, label...) get mapped into git-bug concepts. If you have that, why not go all the way and use the git-bug QL everywhere a filtering is done?

At least one downside I can think of is that the git-bug QL won't have concepts for every native concepts. But it does have a lot and should (?) cover most of the actual usage. Is that really a limitation?

@MichaelMure

Copy link
Copy Markdown
Contributor

Another big thank for your work. I really enjoy using the product.

Thanks! Sadly this require sometimes to say no :-(

What do you think of my alternate proposal?

@nxmatic

nxmatic commented Nov 30, 2020 •

Copy link
Copy Markdown
Author

No worries, that's part of the game.

  • my use case is as follow

    I'm working on multiple repositories and in JIRA I have a single project for all of them. The JIRA projects are more
    designed as products, all the repositories which share the same release cycle are part of the project.

    Before working on a change, I want git-bug to import the issue I'm working on in the repository. This way it's easier to me
    to track my work, I can update the bug, as well I edit the code, it's more natural. When I open up a pull request, I'm
    pushing my bug change, which make the bug changes available to the team (which could be linked in the PR).
    The team will get only comments relative to the work done inside that repository. Which makes sense for me.
    When I will get a status about the pull-request, I'll will push back in JIRA the bug changes (the issue will be
    some kind of aggregator of bugs then).

  • can we think about plugin bridges in git-bug ? Or may be some logic more specific which fit with my needs ? this way I will
    not have to maintain the fork, and I will be able to contribute without breaking your requirements.

  • about the query translator, I agree with you. I just reviewed my kan-ban filter and I think we can translate it in a git-bug
    query. We just have to have a way to contribute the definition of the needed fields mapping in the git-bug bridge. Not for
    extending the bug schema, just for being able to map the query.

    Tags in (nxnos) AND NOT (status = Resolved AND (fixVersion in (NoFixVersionApplicable, JSFMigration) OR project in ("Nuxeo Platform", "Nuxeo ECM Build/Test Environment") OR Resolution in ("Won't Do", Duplicate, "Won't Fix", "Feature Candidate", "Not A Bug", "Cannot Reproduce", "Added to Roadmap", Incomplete)))

@MichaelMure

Copy link
Copy Markdown
Contributor
* can we think about plugin bridges in git-bug ? Or may be some logic more specific which fit with my needs ? this way I will
  not have to maintain the fork, and I will be able to contribute without breaking your requirements.

Go plugins at the moment are fairly broken and barely useful. Even with them, you will still have to follow the changes in git-bug core and maintain your bridge. Hopefully we can find a solution that can suit both of us.

I have a few questions:

  • how do you know what Jira bug you want to import ? Is there a mapping between the git repo and the subset of bugs you want to import ? Why is it not the project?
  • is it acceptable to import slightly too much ? that is, what if the import filter doesn't have all the expressiveness necessary?

Due to the nature of Jira, people can define their own workflow and deeply change how the bugtracker behave, which makes it difficult to implement a bridge that works for everyone. I'm wondering if it would make sense to import some extra Jira field as label, like resolution:wontdo. It would then become possible to filter on that with the git-bug QL.

@nxmatic

nxmatic commented Nov 30, 2020

Copy link
Copy Markdown
Author

I think it's easier to contribute to JIRA the logic we want to select the issues to be exported. I can just map the project on-to a dedicated field which will be set server side dynamically. This way we will align to the simpler model of git-bug that I'm interested to work with.

I agree with your objective of keeping it simple if possible.

@nxmatic

nxmatic commented Dec 1, 2020

Copy link
Copy Markdown
Author

I'm closing this pull request. Thanks for your time.

@nxmatic nxmatic closed this Dec 1, 2020
@MichaelMure

Copy link
Copy Markdown
Contributor

@nxmatic while the core of this PR can't be merged, it seems that you have found a bunch of small issues while journeying the code. Could you PR or report those? That'd be very useful.

Going further, I hope we can keep collaborating on this in the future, to make a tool you enjoy working with.

@nxmatic

nxmatic commented Dec 2, 2020

Copy link
Copy Markdown
Author

yes sure I will in the next days. Is there a channel where we can chat ?

@MichaelMure

Copy link
Copy Markdown
Contributor

There is a gitter chat at https://gitter.im/the-git-bug/Lobby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants