Giter VIP home page Giter VIP logo

git-bz-moz's Introduction

git-bz-moz

A fork of the git-bz tool with a few tweaks specific to bugzilla.mozilla.org, and other fixes not upstreamed.

To authenticate, you need to specify your bugzilla user name and API key.

You can set your bugzilla user name by running: git config --global bz.username

An API key can be obtained here: https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey Once obtained, set the API key by running: git config --global bz.apikey

Some code is imported from the Mozilla version-control-tools repository, revision 35edcee4c73415fa45ff95ed07bb8129d41821f9 The repository is located at https://hg.mozilla.org/hgcustom/version-control-tools/

  • auth.py is copied from pylib/mozhg/mozhg/
  • bz.py and bzauth.py are copied from hgext/bzexport/
  • bzexport.py is a few pieces of code copied from hgext/bzexport/init.py

In addition, a patch to bzauth.py for bug 1336147 was manually applied.

Note: this project requires the Requests library to be installed.

git-bz-moz's People

Contributors

aethanyc avatar amccreight avatar bholley avatar cgwalters avatar chenpighead avatar danwinship avatar djmitche avatar dnarvaez avatar ebassi avatar eeejay avatar ehsan avatar froydnj avatar gittup avatar hellojwilde avatar jankeromnes avatar jlebar avatar jonner avatar lazyparser avatar magcius avatar mrbkap avatar mshal avatar ncalexan avatar neonux avatar nephyrin avatar owtaylor avatar rib avatar standard8 avatar tko avatar yaneti avatar yselkowitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

git-bz-moz's Issues

Unicode decoding error in 'git bz apply'

gecko$ git bz apply 1291642
Traceback (most recent call last):
File "/Users/past/src/git-bz-moz/git-bz", line 1788, in
do_apply(*args)
File "/Users/past/src/git-bz-moz/git-bz", line 1138, in do_apply
attachment_data=True)
File "/Users/past/src/git-bz-moz/git-bz", line 878, in load
bug._load(bug_reference.id, attachment_data)
File "/Users/past/src/git-bz-moz/git-bz", line 822, in _load
self.patches.append(BugAttachment(a))
File "/Users/past/src/git-bz-moz/git-bz", line 784, in init
diff,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 10499: ordinal not in range(128)

Manually downloading the diff and applying it using 'git am' works though.

ImportError: No module named requests

Just pulled and now get:

Traceback (most recent call last):
  File "/home/froydnj/bin/git-bz", line 69, in <module>
    import bzauth
  File "/home/froydnj/src/git-bz-moz/bzauth.py", line 33, in <module>
    import requests
ImportError: No module named requests

I guess we need to say something about having https://pypi.python.org/pypi/requests installed? (Things appear to work OK after I installed that...)

trying to self-review a patch with :me causes errors

Carrying forward review on a patch (or just self-reviewing a trivial patch) by uncommenting the :me option leads to:

Multiple bugzilla users matching ":me":

  1. Dave Justice [:JSON_voorhees / :meandave] <[email protected]>
  2. Tobias Kristiansson [:mediocrity] <[email protected]>
  3. Michael K. Edwards (:medwards) <[email protected]>
  4. Mekki MacAulay [:mekki] <[email protected]>
  5. Agamemnon Skepetaris [:memos] <[email protected]>
  6. Merike (:merike) <[email protected]>
  7. Melissa O'Connor [:melissa] <[email protected]>
  n. None

  a. Abort

which is unpleasant. I'm not sure what broke this, but we should fix it.

Proper VCS integration with bzexport

In my REST API rewrite, I just copied files over from the version-control-tools repository but it should be done more properly, maybe initially by a subrepository and eventually probably by moving this code into that repo.

filing a new bug cannot handle components with slashes in their name

Attempting git bz file -e 'Core/Video/Audio' ID on Mozilla's bugzilla results in (somewhat mysteriously) filing a bug for product "Core", component "Video". Trying to rely on automatically using the setting bz.default-product with git bz file -e 'Video/Audio' ID doesn't work either, because git-bz assumes you're trying to file something in the "Video" product.

2-factor auth on Bugzilla breaks cookie searches

Currently the 2fa implementation on bugzilla has changed cookies to expire at the end of the session. This breaks git-bz-moz, as the cookies are no longer saved to the cookies.sqlite file.

This may change again, follow the dicussion in bug 1202281.

However, it may be time to consider fixing issue #30 and use the API keys that are now be available.

Remove git bz push

This lets you update bugzilla at the same time as you do a push (I think), which doesn't seem super useful given that we have Pulsebot, so I'm inclined to remove it if there are no objections. I have found users at Mozilla for every other command, so maybe somebody uses this one.

RuntimeError: git rev-list didn't return a number of lines divisible by 3

I'm using git-cinnabar, but the stack points to git-bz-moz so I'm filing here.

STR

In a local git-cinnabar clone of mozilla-central (e6b1d0421ae97595aa632d3de79a55ef43fabab8):

$ git bz apply 1109868
Bug 1109868 - XUL popups with an anchor element should hide when the anchor loses its visibility and/or frame

Hide or move popups when the anchor changes
Apply? [yn] y

Applying: 
.git/rebase-apply/patch:628: trailing whitespace.
function waitForPanel(panel, event)  
warning: 1 line adds whitespace errors.
Traceback (most recent call last):
  File "/Users/past/src/git-bz-moz/git-bz", line 1788, in <module>
    do_apply(*args)
  File "/Users/past/src/git-bz-moz/git-bz", line 1170, in do_apply
    commits = rev_list_commits("HEAD^!")
  File "/Users/past/src/git-bz-moz/git-bz", line 203, in rev_list_commits
    raise RuntimeError("git rev-list didn't return a number of lines divisible by 3")
RuntimeError: git rev-list didn't return a number of lines divisible by 3

git-bz-* files left in /tmp

After using git-bz for a while I've noticed a number of files left in /tmp.
I think the bug is that git-bz:edit_template doesn't os.remove the
temporary file.

Remove MozReview cruft from the commit message on export

I have the git mozreview stuff installed, so every patch somehow gets a line added to the end of the commit message like "MozReview-Commit-ID: I3m2BtlZc3b". It would be nice if any place we export a patch, such as when it is attached to a bug, or pushed via hg, that those would get removed.

In case of ambiguity, use bug number from the first line

I have a patch description that looks like:

Bug 12345 - whatever

Bug 60000 did something

This makes git bz attach complain about ambiguity, but it seems reasonable to use the one from the first line if there is ambiguity, or something.

Add testing mode that does not push to bugzilla

It would be nice to have a built-in way to disable any actual changes to Bugzilla, for use when testing why something is going wrong. The ideal way would be a fake server mode that would print out what is getting pushed to it, but something that just aborts before anything real happens might be okay, too. Right now, I just hack this up every time I need to debug something.

git bz apply doesn't understand reviewboard

As an example,

$ git bz apply 1177933
Bug 1177933 - Provide run script or mach command for eslint in mobile/android

$

applies neither of the two patches in the bug. I wonder if this is related to the use of reviewboard...

`git bz apply` uses `git am`

See mozilla/moz-git-tools#52

git bz apply actually calls git am to apply the patch, so if you are trying to apply a patch that is a raw diff without the other formatting niceties then you get a weird error about 'Patch format detection failed.'.

We could try to do some magic fallback to git apply if git am fails, but I think the better long term solution is to add a new git bz am command that uses git am, and make git bz apply actually use git apply. That will cause confusion for existing users but would be more consistent.

make attach do something smarter in the face of inconclusive matches from bugzilla

I tried filing a patch with a reviewer. Unfortunately, the person's bugzilla : name is actually a prefix of two (!) names and so git bz attach fails with a No Conclusive Match error from bugzilla.

It would be nice if it let you resolve the ambiguity, and perhaps even remember that resolution for next time so you don't have to keep doing it.

Insufficient detection of conflict when specifying bug number on the command line

Apparently you can specify a bug number on the command line when attaching a patch, like so:
bz attach -e 12345 @

If the commit message for @ isn't Bug 12345, then it just slaps a new "Bug 12345 - " at the start of the commit message. It should instead report some kind of conflict for this. There's a tricky case where the commit message may contain a description with a bug number, but you still want to add a new bug number to the start, but maybe that's not a big deal.

I'm also not sure if anybody actually uses this bug number feature regularly.

Make add_url do something useful by default

To make add_url do something more useful, Add add-url-method = "subject-prepend:Bug %d -" to your gitconfig. This should be the default. I don't know who wants a random bugzilla URL inserted into their patch.

attach is broken when enabling experimental bugzilla interface

If user sets "Use experimental user interface" to "On", to benefit from the new modal UI, then attach gets broken:

Traceback (most recent call last):
File "/home/alex/codaz/Mozilla/moz-git-tools/git-bz", line 2563, in
do_attach(*args)
File "/home/alex/codaz/Mozilla/moz-git-tools/git-bz", line 1937, in do_attach
bug = Bug.load(handle)
File "/home/alex/codaz/Mozilla/moz-git-tools/git-bz", line 1463, in load
bug._load(bug_reference.id, attachmentdata)
File "/home/alex/codaz/Mozilla/moz-git-tools/git-bz", line 1203, in _load
etree.parse(response)
File "", line 38, in parse
cElementTree.ParseError: not well-formed (invalid token): line 7, column 91

git bz attach -e HEAD leads to ImportError: No module named auth

fitzgen@nfitzgerald-22150 :: (heap-snapshot-file-actor) :: ~/src/mozilla-central-opt
    $ git config --global bz.username [email protected]

fitzgen@nfitzgerald-22150 :: (heap-snapshot-file-actor) :: ~/src/mozilla-central-opt
    $ git config --global bz.apikey <api-key>

fitzgen@nfitzgerald-22150 :: (heap-snapshot-file-actor) :: ~/src/mozilla-central-opt
    $ git bz attach -e HEAD
Waiting for Emacs...
Traceback (most recent call last):
  File "/Users/fitzgen/bin/moz-git-tools/git-bz", line 1759, in <module>
    do_attach(*args)
  File "/Users/fitzgen/bin/moz-git-tools/git-bz", line 1398, in do_attach
    attach_commits(bug, commits, edit=global_options.edit)
  File "/Users/fitzgen/bin/moz-git-tools/git-bz", line 1327, in attach_commits
    bug.create_patch(description, comment, filename, patch, obsoletes=obsoletes, patch_flags=patch_flags)
  File "/Users/fitzgen/bin/moz-git-tools/git-bz", line 817, in create_patch
    requestee_list = self.server.validate_users(flag_values.requestees, flag_name)
  File "/Users/fitzgen/bin/moz-git-tools/git-bz", line 735, in validate_users
    valid_users = bzexport.validate_users(self.ui, self.api_server, self.auth,
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 106, in __getattribute__
    self._load()
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 78, in _load
    mod = _hgextimport(_import, head, globals, locals, None, level)
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 47, in _hgextimport
    return importfunc(name, globals, *args)
  File "/Users/fitzgen/dot-files/bin/moz-git-tools/git-bz-moz/bzexport.py", line 41, in <module>
    from auth import (
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 134, in _demandimport
    mod = _hgextimport(_origimport, name, globals, locals)
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 47, in _hgextimport
    return importfunc(name, globals, *args)
ImportError: No module named auth

When editing a patch before attaching, show patch diff below

It is often good to see the changes for patch #n so I have a better idea of who to ask for review/feedback and if I accidentally left a header include in that isn't used anymore etc. Good to just have a chance to review the patch right before it is attached.

Cannot git bz apply patches in Bug 1375969

I run git bz apply 1375969, and get the following exception. I don't know it's an issue on the tool or on the server.

Exception: REST error on GET to https://bugzilla.mozilla.org/rest/[email protected]: There is no user named 'emilio [email protected]'. Either you mis-typed the name or that user has not yet registered for a Bugzilla account.

Use splitreviewer in git bz file

Ehsan says that "git bz file -e 'Core/Component' ref" will create a new bug from a patch. I should add support for splitreviewer to it, so that the r=foo stuff is removed from the bug subject.

Add a way to assign the bug to yourself when attaching a patch

It would be convenient to be able to assign the bug to yourself when uploading a patch.

The basic feature would be adding an AssignedTo field to the file you edit for bz attach -e. There could be pre-filled in things for the current assignee, for assigning it to yourself, and for resetting it to the default.

There could also be more automatic behavior, like if there is no current assignee you assign it to yourself by default. This could still be commented out from the edit file if you don't want it, but it is the most common use case.

git moves are not changed to hg renames when attaching a patch in bugzilla

STR:

  1. Create a patch with git mv
  2. Attach a patch to bugzilla

Actual Results
No hg rename/move annotations in the patch on bugzilla

Expected Results
hg rename/move annotations.

For example, see https://bug1022594.bugzilla.mozilla.org/attachment.cgi?id=8472973

When I created the patch, I did:
git mv browser/components/loop/test/xpcshell/test_loopservice_get_loop_char_pref.js browser/components/loop/test/xpcshell/test_loopservice_loop_prefs.js
git mv browser/components/loop/test/mochitest/browser_mozLoop_charPref.js browser/components/loop/test/mochitest/browser_mozLoop_prefs.js

These haven't been recorded.

attach is unable to set reviewer flags

When using git bz attach -e SHA, I can uncomment one of the following lines:

#Review: :vingtetun
#Review: [email protected]
#Review: :me+

but with no effect. I'd love to be able to request a review from git bz attach, or carry over a previous r+.

Add URL needs to prompt, and not do heavy work (git branch -r --contains) by default

|git bz attach -e HEAD~8..| was hanging for several minutes with no output -- turns out it was checking if it could add a URL to a commit, and running |git branch --contains -r | to "see if it was pushed anywhere". Though potentially a good warning to have, this command takes 5+ minutes on my repository, which is tracking 8006 remote branches.

Additionally, it is somewhat backwards that we will, by default, rewrite commits to insert bug #s, but only prompt before doing it if some convenience check fails.

attach fails with KeyError: 'data' if the bug has a MozReview patch

When Bug.load() fetches patches in do_attach(), it does so with attachment_data=False. This means the 'data' element isn't present in the attachment, so _process_reviewboard_request() dies with KeyError: 'data'.

I think an easy workaround here is to just ignore MozReview patches if we don't get the 'data' element, though I believe that means you can't obsolete a MozReview patch by using 'git bz attach'. I'm not sure how often that would actually come up though. If there's a better solution here, I'm all for it.

Need better error message when the reviewer doesn't accept the review requests

I post a patch via git bz attach -e with a reviewer set, and got the following exception.

Traceback (most recent call last):
  File "/Users/tlin/Projects/moz-git-tools/git-bz", line 1790, in <module>
    do_attach(*args)
  File "/Users/tlin/Projects/moz-git-tools/git-bz", line 1425, in do_attach
    attach_commits(bug, commits, edit=global_options.edit)
  File "/Users/tlin/Projects/moz-git-tools/git-bz", line 1354, in attach_commits
    bug.create_patch(description, comment, filename, patch, obsoletes=obsoletes, patch_flags=patch_flags)
  File "/Users/tlin/Projects/moz-git-tools/git-bz", line 861, in create_patch
    self.server.auth.rest_request('POST', 'bug/%s/attachment' % self.id, data=o)
  File "/Users/tlin/Projects/moz-git-tools/git-bz-moz/bzauth.py", line 149, in rest_request
    method, url, j['message']))
Exception: <exception str() failed>

I then print the return JSON object, and got the following.

{u'code': 32000, u'message': u"David Baron :dbaron: \u231a\ufe0fUTC-5 (busy February 1-10) <[email protected]> is not currently accepting 'review' requests.", u'documentation': u'http://www.bugzilla.org/docs/tip/en/html/api/', u'error': True}

I'll be nice to have a message saying that the reviewer doesn't accept the review requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.