diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-07-09 09:48:07 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-07-27 14:23:07 +0300 |
commit | 07fdebdbb02fde71d6e656ddd46b967347417502 (patch) | |
tree | 594c2f352499aaac0756e3071a4b7ce2aee0fd34 /bdep/project-email.cxx | |
parent | 8a87a8bc08f0d692f53a0373da3a0a959de13e52 (diff) |
Implement publish command for publishing packages to archive repositories
Diffstat (limited to 'bdep/project-email.cxx')
-rw-r--r-- | bdep/project-email.cxx | 69 |
1 files changed, 11 insertions, 58 deletions
diff --git a/bdep/project-email.cxx b/bdep/project-email.cxx index b85a738..2b836f2 100644 --- a/bdep/project-email.cxx +++ b/bdep/project-email.cxx @@ -4,8 +4,7 @@ #include <bdep/project-email.hxx> -#include <libbutl/filesystem.mxx> - +#include <bdep/git.hxx> #include <bdep/diagnostics.hxx> using namespace butl; @@ -28,12 +27,7 @@ namespace bdep // See if this is a VCS repository we recognize. // - - // .git can be either a directory or a file in case of a submodule. - // - if (entry_exists (prj / ".git", - true /* follow_symlinks */, - true /* ignore_errors */)) + if (git (prj)) { // In git the author email can be specified with the GIT_AUTHOR_EMAIL // environment variable after which things fall back to the committer @@ -41,26 +35,10 @@ namespace bdep // resolved value can be queried with the GIT_AUTHOR_IDENT logical // variable. // - process pr; - bool io (false); - try + if (optional<string> l = git_line (prj, + true /* ignore_error */, + "var", "GIT_AUTHOR_IDENT")) { - fdpipe pipe (fdopen_pipe ()); - - // If git cannot determine the author name/email, it fails verbosely - // so we suppress all diagnostics. - // - pr = start (0 /* stdin */, - pipe /* stdout */, - fdnull () /* stderr */, - "git", - "-C", prj, - "var", - "GIT_AUTHOR_IDENT"); - - pipe.out.close (); - ifdstream is (move (pipe.in), ifdstream::badbit); - // The output should be a single line in this form: // // NAME <EMAIL> TIME ZONE @@ -72,40 +50,15 @@ namespace bdep // The <> delimiters are there even if the email is empty so we use // them as anchors. // - string l; - if (!eof (getline (is, l))) - { - size_t p1, p2; - - if ((p2 = l.rfind ('>' )) == string::npos || - (p1 = l.rfind ('<', p2)) == string::npos) - fail << "no email in git-var output" << endf; + size_t p1, p2; - if (++p1 != p2) - r = string (l, p1, p2 - p1); - } + if ((p2 = l->rfind ('>' )) == string::npos || + (p1 = l->rfind ('<', p2)) == string::npos) + fail << "no email in GIT_AUTHOR_IDENT" << endf; - is.close (); // Detect errors. + if (++p1 != p2) + return string (*l, p1, p2 - p1); } - catch (const io_error&) - { - io = true; // Presumably git failed so check that first. - } - - if (!pr.wait ()) - { - const process_exit& e (*pr.exit); - - if (!e.normal ()) - fail << "process git " << e; - - r = nullopt; - } - else if (io) - fail << "unable to read git-var output"; - - if (r) - return r; } if ((r = getenv ("EMAIL"))) |