sagemath / git-trac-command Goto Github PK
View Code? Open in Web Editor NEWA "git trac" subcommand for git
License: GNU General Public License v3.0
A "git trac" subcommand for git
License: GNU General Public License v3.0
While git-trac-command
is currently limited to working with Bash,
I wish it would be possible to make it work with Zsh too.
This was output in yellow:
remote: Trac #7660: Commit changed to 5d9341.
To ssh://[email protected]/sage.git
de2f0a0..5d93415 HEAD -> u/rws/ticket/7660
There are cases where you don't want git trac try doing self.git.fetch('trac', 'develop').
E.g. I need (sage's) #16440 to build docs, while the current 'develop' does not have it merged. Perhaps 'try' should get an option to specify that develop should not be used as the base.
Either git-trac will have to change its behaviour or I must ask you to send me a new password everytime I lose it (because I need the old to set a new one, and there's no Forgot Password button on trac). That new password might suffer the same fate though.
So please 8)
Alternatively, how about a reset passwd button inside trac preferences? My browser still knows the old passwd.
Suggested in the
See this sage-devel thread, and especially this post which is my understanding of the problem at the moment.
With non-english localization, git-trac seems not to appreciate Git's error messages, and instead of informing the user what Git originally raised, a str() error
is printed instead.
We observed this on a french machine (at SageDays75). I have english localization on my machine and my initial tries at getting Git to print french on my machine failed, so I can't reproduce it. But I thought it worth reporting anyway.
well, readme needs to be updated, I guess.
Use case:
(no branch exists for 12345)
$ git trac checkout 12345
Guessing remote branch...
Warning: remote branch is based on 6.2.beta4 but your development branch is 6.2.beta8. Proceed (y/n)
Or something like that. Or even ask when devel is less than current. I'm completely naive about whether this is possible but it would be a killer application.
Output is:
.../sage-git/src/sage/coding» git trac --help
No manual entry for git-trac
On my system it is symlink to the bin/git-trac
command in this repo.
since there is
$ git trac print 12345
the next desirable thing would be to add comments to the ticket...
Is it hard to implement?
I just succeeded setting up git trac over ssh, and the push did work, but nevertheless I got a stacktrace:
File "/usr/lib/python2.7/site-packages/git_trac/git_repository.py", line 162, in push
self.set_upstream(remote_branch)
File "/usr/lib/python2.7/site-packages/git_trac/git_repository.py", line 127, in set_upstream
self.git.branch('--set-upstream-to', 'remotes/trac/{0}'.format(remote))
File "/usr/lib/python2.7/site-packages/git_trac/git_interface.py", line 335, in meth
return self.execute(git_cmd, *args, **kwds)
File "/usr/lib/python2.7/site-packages/git_trac/git_interface.py", line 322, in execute
popen_stderr=subprocess.PIPE)
File "/usr/lib/python2.7/site-packages/git_trac/git_interface.py", line 257, in _run
raise GitError(result)
git_trac.git_error.GitError: git returned with non-zero exit code (128) when executing "git branch --set-upstream-to remotes/trac/u/rws/ticket/7660"
STDERR: fatal: Not a valid object name: 'remotes/trac/u/rws/ticket/7660'.
There is some inconsistency in -h
vs. --help
:
$ git trac --help
No manual entry for git-trac
$ git trac -h
....
$ git trac pull -h
usage: git-trac pull [-h] [ticket_or_branch]
git-trac pull: error: argument ticket_or_branch: invalid TicketOrBranch value: 'help'
2
Exiting.
$ git trac pull --help
usage: git-trac pull [-h] [ticket_or_branch]
positional arguments:
ticket_or_branch Ticket number or remote branch name
optional arguments:
-h, --help show this help message and exit
It would be great if all subcommands were to support the -h
switch, as the online help claims they should.
It would be even greater if we had manual pages for --help
written and made available on the path through the add-on, but I don't know if the latter is even possible.
With a bad token,
% git trac config --user=fake --token=fake
Saved trac username.
Saved trac token.
Trac xmlrpc URL:
https://trac.sagemath.org/xmlrpc (anonymous)
https://trac.sagemath.org/login/xmlrpc (authenticated)
realm sage.math.washington.edu
Using token-based authentication with the provided JWT token
generated by the Trac server. If a username and password were
configured as well, the token takes priority. To unset the
token use:
git trac config --token=
Retrieving SSH keys...
On the other hand, a bad password attempt raises an git_trac.trac_error.TracAuthenticationError:
git trac
returns this error:
/usr/bin/env: ‘python’: No such file or directory
My system is Ubuntu, so (like most Debian-derived distributions) by default python2
runs python 2.x, and python3
is used for Python 3.x. python
doesn't do anything unless the user has configured their system accordingly.
I think this script should be set up so it will run on one of the most popular linux familes without modification.
This sometimes happens:
$ git trac checkout 19525
Loading ticket #19525...
Newly created local branch: t/19525/improve_glpk_error_handling
Traceback (most recent call last):
File "/home/jdemeyer/local/bin/git-trac", line 18, in <module>
cmdline.launch()
File "/home/jdemeyer/local/src/git-trac-command/git_trac/cmdline.py", line 209, in launch
app.checkout(args.ticket_or_branch, args.branch_name)
File "/home/jdemeyer/local/src/git-trac-command/git_trac/app.py", line 115, in checkout
self._checkout_ticket(int(ticket_or_branch), branch_name)
File "/home/jdemeyer/local/src/git-trac-command/git_trac/app.py", line 129, in _checkout_ticket
self.repo.create(local)
File "/home/jdemeyer/local/src/git-trac-command/git_trac/git_repository.py", line 133, in create
self.git.branch(local, 'FETCH_HEAD')
File "/home/jdemeyer/local/src/git-trac-command/git_trac/git_interface.py", line 341, in meth
return self.execute(git_cmd, *args, **kwds)
File "/home/jdemeyer/local/src/git-trac-command/git_trac/git_interface.py", line 328, in execute
popen_stderr=subprocess.PIPE)
File "/home/jdemeyer/local/src/git-trac-command/git_trac/git_interface.py", line 263, in _run
raise GitError(result)
git_trac.git_error.GitError: git returned with non-zero exit code (128) when executing "git branch t/19525/improve_glpk_error_handling FETCH_HEAD"
STDERR: fatal: A branch named 't/19525/improve_glpk_error_handling' already exists.
In this case, git trac checkout 19525
should just checkout the already-existing branch.
The behaviour of git-trac-checkout is both unexpected and leads to problems for the user:
git trac checkout 12345
(fails for some reason, e.g. changes in current branch not committed)
...
git trac checkout 12345
...STDERR: fatal: A branch named 't/12345/very_long_string' already exists.
Now the user has to delete the branch and give the same command a third time.
Currently git trac creates extremely long branch names like at for example: making_disjointunionenumeratedsets_check_for_finiteenumeratedsets_when_category_is_not_set
at #21218 . This not only renders really awkwardly on trac, but is also highly inconvenient for people using git the hard way.
Certainly it is an overkill to do the config steps (or even to get a trac account) if one just wants to pull from trac tickets.
See https://groups.google.com/d/msg/sage-devel/qMtxE-UFbZY/dUER4utXkQsJ
While configuring git and trac through guidelines given here docs.sagemath
git trac config --user USERNAME --pass 'PASSWORD'
gives as error
Saved trac username.
Saved trac password.
Trac xmlrpc URL:
https://trac.sagemath.org/xmlrpc (anonymous)
https://trac.sagemath.org/login/xmlrpc (authenticated)
realm sage.math.washington.edu
Username: diveshkr-code
Password: ***********
Retrieving SSH keys...
Traceback (most recent call last):
File "/home/diveshcode/git-trac-command/bin/git-trac", line 17, in
cmdline.launch()
File "/home/diveshcode/git-trac-command/git_trac/cmdline.py", line 284, in launch
app.print_config()
File "/home/diveshcode/git-trac-command/git_trac/app.py", line 391, in print_config
for key in self.trac.get_ssh_fingerprints():
File "/home/diveshcode/git-trac-command/git_trac/trac_server.py", line 111, in get_ssh_fingerprints
for key in self.get_ssh_keys():
File "/home/diveshcode/git-trac-command/git_trac/trac_server.py", line 103, in get_ssh_keys
return self.authenticated_proxy.sshkeys.getkeys()
File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in call
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request
return self.single_request(host, handler, request_body, verbose)
File "/home/diveshcode/git-trac-command/git_trac/digest_transport_py2.py", line 127, in single_request
response = self.opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
context=self._context)
File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)>
$ git trac config --user .... --pass ......
Traceback (most recent call last):
File "/usr/local/src/sage/git-trac-command/bin/git-trac", line 18, in
cmdline.launch()
File "/usr/local/src/sage/git-trac-command/git_trac/cmdline.py", line 156, in launch
from .app import Application
File "/usr/local/src/sage/git-trac-command/git_trac/app.py", line 30, in
from .git_repository import GitRepository
File "/usr/local/src/sage/git-trac-command/git_trac/git_repository.py", line 30, in
from .git_commit import GitCommit
File "/usr/local/src/sage/git-trac-command/git_trac/git_commit.py", line 23, in
from functools import total_ordering
ImportError: cannot import name total_ordering
(this is on OSX 10.6.8, with python 2.6.1)
Does one need Python version 2.7 or later?
Provide a way to start from latest develop and apply several tickets.
For example, reading this sage-release post one would like to
$ git trac try 29061 30603 30610
$ git trac find 712306534f66dcf0000543fd6958f1c0c99a749f
Error: too many values to unpack (expected 3)
lately I found that for reviewing tickets it's quicker to merge the ticket branch into the current local branch, as doing 'git trac checkout 12345' often sets you back hundreds of commits, and often needs the dreaded (esp. by people without a fast multicore machine) 'make distclean && make' to have a everything, including docs, built.
I wonder if there should be a special 'git trac merge 12345' for such occasions.
I think it would be easy to add a spot in attributes
for this.
def close_ticket(self, ticket):
comment = ''
attributes = {
'_ts': ticket.timestamp,
'status': 'closed',
'resolution': 'fixed',
}
notify = True
if len(ticket.commit) > 0:
attributes['branch'] = ticket.commit
return self.trac.authenticated_proxy.ticket.update(
ticket.number, comment, attributes, notify)
But not so easy to guess what the number of the release will be. There are tools to find the previous stable or unstable release in git_trac/git_repository.py but I don't see any support for adding the release version to git_trac/releasemgr/cmdline.py One could do something with
parser_close.add_argument('--version', ...
and similarly for parser_merge
if --close
was given, but maybe this is more invasive than desired?
Greetings. I first installed this program locally by doing
python setup.py install --user
but then "git trac cheat-sheet" is unable to find any .pdf, as none is installed anywhere.
For a Debian package I just made from this, I put the file in /usr/share/doc/git-trac-command/git-cheat-sheet.pdf.gz and modified git_trac/cmdline.py accordingly but maybe the python install should put the file in "share/pyshared/git_trac".
BTW: I've already used the program and it works great.
Thanks.
I'm using a simple shell script git-trac-merge
for it, but it would be nice to have something like this as a built-in command.
for a in $*; do git trac fetch $a && git merge --no-ff -m "Merge #$a" FETCH_HEAD; done
With Sage 8.8 or later:
$ git trac log 12345
Error: parsing log failed at "b5c9cf037cbce672101725f269470135b9b2c5c4 Updated SageMath version to 8.8"
The same command works with Sage 8.7.
git trac checkout 8162
creates branch t/8162/ticket/8162
where t/8162
would be sufficient.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.