Coder Social home page Coder Social logo

bump's People

Contributors

marksteve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bump's Issues

Failures should have non-zero exit codes

When cancelling or encountering other errors, bump should exit with an error code.

$ bump package.json && git add . && commit -m "Bump version."
package.json: 0.2.0 => 0.2.1
Is this ok? y/n n
Cancelled.
[master b72572b] Bump version.
 1 files changed

ValueError: zero length field name in format

$ cat expo/package.json
{
  "name": "expo",
  "version": "0.1.1",
  "engines": { "node": ">=0.8.0" },
  "dependencies": {
    "commander": "1.1.x",
...snip

$ bump package.json
Traceback (most recent call last):
  File "/Users/rsc/.zsh/bin/bump", line 122, in <module>
    main()
  File "/Users/rsc/.zsh/bin/bump", line 100, in main
    match['bumped_version_string']))
ValueError: zero length field name in format

ignore XML versions

Given this xml document:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp" version="0.9.3"
  xmlns="http://www.w3.org/ns/widgets"
  xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>MyApp<name>
    ....
</widget>

...doing bump config.xml will bump <?xml version='1.0' ..?>, not the intended version (version="0.9.3").

Using bump on a file that has non ascii characters, bump fails and erases the whole file

Hello!

I just tried bump. When there is a proper setup.py file, but with non-ascii characters (the encoding is declared on top of the file!), bump spits an error and overwrites the file with nothing.

Here's the traceback.

george@winterfell ~/projetos/corporativo/django-comum $ bump setup.py 
setup.py: 1.0.1 => 1.0.2
Is this ok? y/n y
Traceback (most recent call last):
  File "/usr/local/bin/bump", line 9, in <module>
    load_entry_point('bump==0.3.0', 'console_scripts', 'bump')()
  File "/usr/local/lib/python2.7/dist-packages/bump.py", line 123, in main
    bumped_version_string + content[match['match'].end(1):])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 138-139: ordinal not in range(128)

Thanks and enhancments

First, thanks for this little script.

I am getting tired of doing this plus my sphinx docs plus my package '--version' options all by hand.

I forked bump and plan to add automation to bumping the other places in a package that might need to reflect the version number as well.

If you like I will send you a pull request when I have it running.

Thanks again,

Gus

Refactor

Hey, here's some quick refactors you can do :-)

Your lines that look like:

print(filename, ':', match['version_string'], '=>', match['new_version_string'])

Are probably better written using string formatting:

print("%s: %s => %s" % (filename, match['version_string'], match['new_version_string']))

You can refactor if-else blocks to be less indented, like this one:

    if __input('Is this ok? y/n ').lower() == 'y':
       # ....
    else:
        print('Cancelled')
        exit(1)

Which can be written better as:

    if __input('Is this ok? y/n ').lower() != 'y':
        print('Cancelled')
        exit(1)

    # ...

You can move some stuff into functions, like the argparser generation.

Here's a quick attempt to put these together. I posted this as a gist and not a pull request, it's more of a "hey check this out" kinda deal. :-)

Awesome work by the way!

Shebang

It'd be nice to have the first line start with a shebang.

#!/usr/bin/env python

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.