n0v1c3 / vira

Create and update your Jira issues while inside Vim!
MIT License
94 stars 12 forks source link

VIRA-213: Autoload of Vira Server/Project #70

Closed nathanaelcunningham closed 3 years ago

nathanaelcunningham commented 3 years ago

How exactly does When you're in a git repo, vira will auto-load your pre-defined settings by matching the local repo name from file path. work? I have a vira_projects.json added to the default path following the readme, but whenever i try to look at issues i have to select the server first.

mikeboiko commented 3 years ago

vira tries a couple of different methods in this order.

  1. Try to get local git repo using git rev-parse --show-toplevel
  2. Get last folder name using pwd

See code snippet from load_project_config() in vira/python/Vira/vira_api.py:

            repo = run_command('git rev-parse --show-toplevel')['stdout'].strip()
            if not self.vira_projects.get(repo):
                repo = repo.split('/')[-1]
            if not self.vira_projects.get(repo):
                repo = run_command('pwd')['stdout'].strip()
            if not self.vira_projects.get(repo):
                repo = repo.split('/')[-1]
            if not self.vira_projects.get(repo):
                repo = '__default__'
                if not self.vira_projects.get('__default__'):
                    return
n0v1c3 commented 3 years ago

Hello @nathanaelcunningham the main goal was put in by @mikeboiko. When you are inside a folder and run vira ie connect to the server it will check that list that @mikeboiko mentioned above to see if there is a best fit otherwise fall to the __default__ settings or NO filter if there is no file at all. (Here simply the vira_servers.json/yaml file will be needed.

If you are inside vim once vira is already running a filter basically already exists this is where the commands like ViraFiterEdit and ViraFilterProjects will be useful. You can use these commands to edit the filters "on the fly" while using the "ViraFilterReset" to get back to NO filters other than the server you are connected to.

It looks like I may need to do a patch for the highlighting in the ViraFilterProjects menu but here are the key mappings and still appear to work:

n0v1c3 commented 3 years ago

There is also a bit better breakdown of the json format in #41 I will probable just update that at the same time and just call this one a bit easier for others.

n0v1c3 commented 3 years ago

As I am reading to begin cleanup I can see som confusion is possible. I will try to make a simple as can be for here is json and here is yaml with a list bellow for what is each row. This way we can have simply ONE section for "here is a file and how you can make a copy for what you need it to do for you"

I personally use the "ViraFilterEdit" command a lot as I can simply take what I make from there and put it inside my vira_projects file if I want to attach it to a directory.

n0v1c3 commented 3 years ago

https://stackoverflow.com/questions/62642858/captcha-challenge-on-login-with-python-jira

n0v1c3 commented 3 years ago

@nathanaelcunningham hopefully to help you out, this is working for me. You should not need to put the filters into arrays if there is only one however it will just be easier to show them this way from the get go. It is also important that the filters are list inside of a list. This was mostly because there is another list for new issues. I know it is sloppy but that was to help break it down for you.

{  
  "__default__": {
    "server": "https://jira.testing.ca"
  },
  "__n0v1c3__": {
    "server": "https://n0v1c3.atlassian.net"
  },
  "__testing__": {
    "server": "https://jira.testing.ca"
  },
  "vira": {
    "template": "__testing__",
    "filter": {
      "project": ["VIRA"],
      "assignee": ["travis"],
      "fixVersion": ["0.5.0"]
    }
  },
  "vim": {
    "server": "https://jira.testing.ca",
    "filter": {
      "project": "VIM"
    }
  },
  "workProject": {
    "server": "https://jira.work.net",
    "filter": {
      "project": ["HARD", "EASY", "MONEY"],
      "fixVersion": ["0.0.3", "0.0.4", "0.0.5"]
    }
  }
}
n0v1c3 commented 3 years ago

@nathanaelcunningham give a test on the VIRA-213 branch if you have a chance. I think that you had only one server and that was a bug in my code.

Plug 'n0v1c3/vira', {'branch': 'VIRA-213'}
nathanaelcunningham commented 3 years ago

@n0v1c3 That branch is working. I tested the projects file with just the default server and that worked. Ill try project specific server setup in a bit.

n0v1c3 commented 3 years ago

I have a feeling this one has floated past me for a little while now as my test were all done with multiple servers setup. One more test on a list that is being created. Thanks!

I did start with a README cleanup so I will probably do a quick wrapup of that and push it to master for the rest of the people. It appears to work fine on vim and nvim. Multiple servers still appears to work and should just open that menu if a __default__ is not defined.

I am sure some deeper testing will find something wrong and I know I took a sloppy way out but I am not worried with were my code is going for VIRA 0.5.0. The menus are going to completely change how they load and this will be affected.

n0v1c3 commented 3 years ago

@nathanaelcunningham and @mikeboiko I daringly moved it to the master branch so lets see how that goes for everyone out there. It did not seem to break anythiny I had set up and only made it better so I cannot see to many complaints coming.

Thanks @nathanaelcunningham, I know that I started with the README and your config but I am sure there are other ways to keep making it better as I don't think I will ever get to finish VIRA-213. (It is a README based issue and here we are changing the login process).

n0v1c3 commented 3 years ago

@nathanaelcunningham I assume not much new has come up for yourself on this? It is on the master branch and haven't heard much so far.

I will call it closed and new ones can be opened as needed.