Skip to content

Commit

Permalink
Workaround for jira integration in bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Jul 5, 2024
1 parent 239074c commit 790f7b7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ require('lazy').setup({
})
```

## Configfile

Create a `~/.config/ndoo/config.json` file with the following content:

```json
{
"bitbucket_use_jira_issues": true,
"bitbucket_username": "gorillamoe",
"bitbucket_app_password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
```

The `bitbucket_use_jira_issues` key optional and only needed if you want to use the Jira integration
in your Bitbucket repositories.

The `bitbucket_username` and `bitbucket_app_password` are required for the Bitbucket integration.

You can obtain the `bitbucket_app_password` by going to your Bitbucket settings and
creating a new app password.

The username is your Bitbucket username.

## Public methods

### `require('ndoo').open()`
Expand Down
6 changes: 6 additions & 0 deletions lua/ndoo/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local CONFIG = require("ndoo.config")
local JSON_CONFIG = CONFIG.get_config_json()
local HELPER = require("ndoo.helper")
local PORTALS = require("ndoo.portals")
local GITHUB = require("ndoo.portals.github")
Expand Down Expand Up @@ -181,6 +183,10 @@ function M.issues()
open_slug("issues/" .. issue_number)
end)
elseif PORTALS.is_bitbucket() then
if JSON_CONFIG.bitbucket_use_jira_issues ~= nil then
open_slug("jira")
return
end
BITBUCKET.show_bitbucket_issues_picker(function(issue_number)
if (issue_number == nil) then
print("no issue selected")
Expand Down
14 changes: 10 additions & 4 deletions lua/ndoo/portals/bitbucket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ local JSON_CONFIG = CONFIG.get_config_json()
local USERNAME = JSON_CONFIG.bitbucket_username
local APP_PASSWORD = JSON_CONFIG.bitbucket_app_password
local BASE64_CREDS = vim.base64.encode(USERNAME .. ":" .. APP_PASSWORD)
local REPO_OWNER = nil
local REPO_NAME = nil

local M = {}

M.base_url = "https://bitbucket.org/"
M.API_BASE_URL = "https://api.bitbucket.org"
M.API_BASE_URL = "https://api.bitbucket.org/2.0/repositories/"

local function get_data(slug)
local repo_owner = M.get_bitbucket_repo_owner()
local repo_name = M.get_bitbucket_repo_name()
local curl_cmd = "curl -s -X GET -H 'Authorization: Basic " .. BASE64_CREDS .. "' " .. M.API_BASE_URL .. "/2.0/repositories/" .. repo_owner .. "/" .. repo_name .. "/" .. slug
if REPO_OWNER == nil then
REPO_OWNER = M.get_bitbucket_repo_owner()
end
if REPO_NAME == nil then
REPO_NAME = M.get_bitbucket_repo_name()
end
local curl_cmd = "curl -s -X GET -H 'Authorization: Basic " .. BASE64_CREDS .. "' " .. M.API_BASE_URL .. REPO_OWNER .. "/" .. REPO_NAME .. "/" .. slug
local jsonstr = vim.fn.system(curl_cmd)
local data = vim.fn.json_decode(jsonstr)
return data
Expand Down

0 comments on commit 790f7b7

Please sign in to comment.