GithubHelp home page GithubHelp logo

nasqueron / resolve-hash Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 9 KB

Try to find URL to represent VCS hash in Phabricator, Gerrit, GitHub, GitLab

License: BSD 2-Clause "Simplified" License

Makefile 9.06% Python 90.94%

resolve-hash's Introduction

resolve-hash

Allow to resolve a hash to a known URL representation.

Usage

resolve-hash <hash> outputs URL matching the hash

Output: URL matching the hash, if found

Exit code:

  • 0 if the hash has been found
  • 1 if the hash has NOT been found

Example:

$ resolve-hash 8d8645468228
https://devcentral.nasqueron.org/rKERUALD8d8645468228

$ resolve-hash 00000000000000
https://github.com/seungwonpark/ghudegy-chain/commit/00000000000000c06d2e8c36f247206a9a4b1c63

$ resolve-hash not_a_hash
$ echo $?
1

Why this package?

Terminator has a comprehensive plugins' system to offer extra features, like resolve console output as links.

Meanwhile, it's sometimes convenient to open a link in a browser, especially if the VCS hash is resolved to the code review system.

Hash sources

VCS

  • Phabricator, browsing your .arcrc file to know the instances you work with
  • Gerrit, if explicitly configured
  • GitHub
  • GitLab, if you provide a token, as search queries must be authenticated

Configuration

You can provide a configuration by creating a $HOME/.config/resolve-hash.conf file.

Configuration is a YAML file.

Variable Description Format
gerrit URL to your Gerrit instances List of strings
gitlab_public_token Personal token for GitLab.com string

Example:

gerrit:
  - https://gerrit.wikimedia.org/r/

gitlab_public_token: glpat-sometoken

Use as a library

You can use the package as a library to resolve hashes in your application:

from resolvehash.vcs import phabricator

url = phabricator.query_phabricator_instances("/home/luser/.arcrc", "8d8645468228")
print(url)

Extend the code

How to add a new VCS source?

If you wish to add a new VCS source, add a method in VcsHashSearch, then add it to get_search_methods.

How to add a hash source?

If you wish to extend this script by searching Foo in addition to VCS, you can create a class FooHashSearch with the following methods:

  • __init__(self, config, needle_hash): constructor called by the script
  • search(self): perform your search, return a URL or None

How can I contribute?

You can commit your changes to the upstream by following instructions at https://agora.nasqueron.org/How_to_contribute_code

The canonical repository is https://devcentral.nasqueron.org/source/resolve-hash.git

License

BSD-2-Clause, see LICENSE file.

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.