pike.git / lib / modules / Git.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/Git.pmod/module.pmod:37:   //! to specify the Git repository for the current directory.   //!   //! @param command   //! Git subcommand to execute.   //!   //! @param args   //! Arguemnts for @[command].   //!   //! @returns   //! Returns the corresponding @[Process.Process] object. + //! + //! @seealso + //! @[git()], @[try_git()]   Process.Process low_git(mapping(string:mixed) options,    string git_dir, string command, string ... args)   {    if (git_dir) {    return Process.Process(({ git_binary, "--git-dir", git_dir,    command, @args }), options);    }    return Process.Process(({ git_binary, command, @args }), options);   }   
pike.git/lib/modules/Git.pmod/module.pmod:61:   //! to specify the Git repository for the current directory.   //!   //! @param command   //! Git subcommand to execute.   //!   //! @param args   //! Arguemnts for @[command].   //!   //! @returns   //! Returns the output on @tt{stdout@} from running the command - //! on success, and throws and error on failure. + //! on success, and throws an error on failure. + //! + //! @seealso + //! @[try_git()], @[low_git()]   string git(string git_dir, string command, string ... args)   {    array(string) cmd;    if (git_dir) {    cmd = ({ git_binary, "--git-dir", git_dir, command, @args });    } else {    cmd = ({ git_binary, command, @args });    }    mapping(string:string|int) res = Process.run(cmd);    if (res->exitcode) {    werror("CWD: %O\n", getcwd());    error("Git command '%s' failed with code %d:\n"    "%s", cmd*"' '", res->exitcode, res->stderr||"");    }    return res->stdout||"";   }    -  + //! Attempt to run a git command and get its output. + //! + //! @param git_dir + //! Directory containing the Git repository. May be @expr{UNDEFINED@} + //! to specify the Git repository for the current directory. + //! + //! @param command + //! Git subcommand to execute. + //! + //! @param args + //! Arguemnts for @[command]. + //! + //! @returns + //! Returns the output on @tt{stdout@} from running the command + //! on success, and @expr{0@} (zero) on failure. + //! + //! @note + //! This is a convenience function, and there is no way to get + //! the specific cause for failures other than rerunning the + //! command with e.g. @[git()]. + //! + //! @seealso + //! @[git()], @[low_git()] + string try_git(string git_dir, string command, string ... args) + { +  mixed err = catch { +  return git(git_dir, command, @args); +  }; +  return 0; + } +    //! Hash algorithm for blobs that is compatible with git.   string hash_blob(string data)   {    Crypto.SHA1 sha1 = Crypto.SHA1();    sha1->update(sprintf("blob %d\0", sizeof(data)));    sha1->update(data);    return String.string2hex(sha1->digest());   } -  +