1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #7910 resolved

API: show if user is not mapped to any Bitbucket account (BB-9078)

Juha Kuitunen
created an issue

Sometimes user commits to repo with different name and email address, usually after fresh install of git or mercurial. Let's say new username in raw hg commit is someone <name@example.com>. If the user has not mapped this email to his account, Bitbucket website says Author not mapped to Bitbucket user. when viewing the commit.

Example API request which is affected by this issue: GET repositories/{accountname}/{repo_slug}/changesets/{raw_node}/

It has fields
"raw_author": "someone <name@example.com>"
"author": "someone"

If the user is not mapped to any Bitbucket account, it is possible the author field contains some existing username that has nothing to do with the commit. In these cases I'd like to have a new boolean field isUserMapped so I can either use the author when it's mapped (for example to create a link to user account) or raw_author if user is not mapped.

Comments (10)

  1. Nicolas Venegas

    Hi Juha Kuitunen

    Our upcoming 2.0 API for commits does make this distinction, e.g., for an umapped user:

    {
        "author": {
            "raw": "Junio C Hamano <gitster@pobox.com>"
        },
        "date": "2013-07-05T08:16:27+00:00",
        "hash": "f8abaebab3fe1a1b873f9636ea410ac4007c8fa8",
        "links": [
            {
                "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/commit/f8abaebab3fe1a1b873f9636ea410ac4007c8fa8",
                "rel": "self"
            },
            {
                "href": "https://bitbucket.org/mirror/git/commits/f8abaebab3fe1a1b873f9636ea410ac4007c8fa8",
                "rel": "html"
            },
            {
                "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/patch/f8abaebab3fe1a1b873f9636ea410ac4007c8fa8",
                "rel": "patch"
            }
        ],
        "message": "Merge branch 'maint'\n\n* maint:\n  fixup-builtins: retire an old transition helper script\n",
        "parents": [
            {
                "hash": "04f2ddda8426d3ae46d52d9dcbfc00bd3c52e645",
                "links": [
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/commit/04f2ddda8426d3ae46d52d9dcbfc00bd3c52e645",
                        "rel": "self"
                    },
                    {
                        "href": "https://bitbucket.org/mirror/git/commits/04f2ddda8426d3ae46d52d9dcbfc00bd3c52e645",
                        "rel": "html"
                    },
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/patch/04f2ddda8426d3ae46d52d9dcbfc00bd3c52e645",
                        "rel": "patch"
                    }
                ]
            },
            {
                "hash": "531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                "links": [
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/commit/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                        "rel": "self"
                    },
                    {
                        "href": "https://bitbucket.org/mirror/git/commits/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                        "rel": "html"
                    },
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/patch/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                        "rel": "patch"
                    }
                ]
            }
        ],
        "repository": {
            "full_name": "mirror/git",
            "links": [
                {
                    "href": "https://bitbucket.org/api/1.0/repositories/mirror/git",
                    "rel": "self"
                },
                {
                    "href": "https://bitbucket.org/mirror/git",
                    "rel": "html"
                },
                {
                    "href": "https://bitbucket.org/mirror/git.git",
                    "rel": "clone",
                    "type": "https"
                },
                {
                    "href": "ssh://git@bitbucket.org/mirror/git.git",
                    "rel": "clone",
                    "type": "ssh"
                }
            ]
        }
    }
    

    And for a mapped user:

    {
        "author": {
            "raw": "Ramkumar Ramachandra <artagnon@gmail.com>",
            "user": {
                "display_name": "Ramkumar Ramachandra",
                "links": [
                    {
                        "href": "https://bitbucket.org/api/1.0/users/artagnon",
                        "rel": "self"
                    },
                    {
                        "href": "https://bitbucket.org/artagnon",
                        "rel": "html"
                    }
                ],
                "username": "artagnon"
            }
        },
        "date": "2013-07-04T05:47:53+00:00",
        "hash": "531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
        "links": [
            {
                "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/commit/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                "rel": "self"
            },
            {
                "href": "https://bitbucket.org/mirror/git/commits/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                "rel": "html"
            },
            {
                "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/patch/531c8dd4fb18e653d6170d367e4b23c3164d5ce0",
                "rel": "patch"
            }
        ],
        "message": "fixup-builtins: retire an old transition helper script\n\nThis script was added in 36e5e70 (Start deprecating \"git-command\" in\nfavor of \"git command\", 2007-06-30) with the intent of aiding the\ntransition away from dashed forms.\n\nIt has already been used to help the transision and served its\npurpose, and is no longer very useful for follow-up work, because\nthe majority of remaining matches it finds are false positives.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nReviewed-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n",
        "parents": [
            {
                "hash": "81a199bb1cd483321962a7bfe5db33980bbf0f01",
                "links": [
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/commit/81a199bb1cd483321962a7bfe5db33980bbf0f01",
                        "rel": "self"
                    },
                    {
                        "href": "https://bitbucket.org/mirror/git/commits/81a199bb1cd483321962a7bfe5db33980bbf0f01",
                        "rel": "html"
                    },
                    {
                        "href": "https://bitbucket.org/api/2.0/repositories/mirror/git/patch/81a199bb1cd483321962a7bfe5db33980bbf0f01",
                        "rel": "patch"
                    }
                ]
            }
        ],
        "repository": {
            "full_name": "mirror/git",
            "links": [
                {
                    "href": "https://bitbucket.org/api/1.0/repositories/mirror/git",
                    "rel": "self"
                },
                {
                    "href": "https://bitbucket.org/mirror/git",
                    "rel": "html"
                },
                {
                    "href": "https://bitbucket.org/mirror/git.git",
                    "rel": "clone",
                    "type": "https"
                },
                {
                    "href": "ssh://git@bitbucket.org/mirror/git.git",
                    "rel": "clone",
                    "type": "ssh"
                }
            ]
        }
    }
    

    Feel free to use this particular API to get commit details (documentation for it should be out soon). Though note that the "link" objects are about to change in the response from

    [{"href": "...", "rel": "self"}, {"href": "...", "rel": "html"}]
    

    to

    {"self": {"href": "..."}, "html": {"href": "..."}}
    

    Let me know if this suffices.

    Cheers

    Nicolas

  2. Erik van Zijst staff

    Michael Müller We're working on a 2.0 upgrade for an important part of the site's functionality, with the commits API being only a part of this. However, the approach we're taking is a progressive one, where we'll be upgrading APIs one after another.

    That new commits API is about to be published and so is a comprehensive pull request API (early next month, but you can already use it: https://api.bitbucket.org/2.0/repositories/pypy/pypy/pullrequests) and patches.

    As we upgrade APIs, we'll deprecate the old ones, but we'll likely enter a long period where both 1.0 and 2.0 APIs coexist.

  3. Michael Müller

    Erik van Zijst I'm developing an app that's going to use some of the APIs. I'd like to avoid implementing an API client just to see that there's a new version on the next day.

    Maybe you could add a little note in the documentation when you start work on a new API?

  4. Erik van Zijst staff

    What APIs are you using? What we're about to release include:

    • pullrequest API (this is a new API, with no deprecated old version)
    • commit (deprecates Changeset Resource)
    • commits API (sophisticated DAG traversal, akin to the raw git rev-list command)
    • patches (offers raw cset and PR patches and arbitrary branch comparison diffs -- new API with no deprecated old version)

    That will be the initial set, but other 2.0 APIs will hopefully follow in the future.

  5. Michael Müller

    Ok, I don't use any of the mentioned APIs.

    I hope so too. The events resources lack important information like issue ids. This links concept would be very helpful there!

    I was just suggesting you tell potential implementers when you plan to deprecate an API. They might want to wait for the new API to arrive.

  6. Log in to comment