Revision: 76523
          http://sourceforge.net/p/brlcad/code/76523
Author:   starseeker
Date:     2020-07-27 18:35:13 +0000 (Mon, 27 Jul 2020)
Log Message:
-----------
git branch -a --contains won't always output just branch names - see if we can 
filter out the lines we don't want

Modified Paths:
--------------
    brlcad/trunk/misc/repoconv/verify/verify.cpp

Modified: brlcad/trunk/misc/repoconv/verify/verify.cpp
===================================================================
--- brlcad/trunk/misc/repoconv/verify/verify.cpp        2020-07-27 18:12:02 UTC 
(rev 76522)
+++ brlcad/trunk/misc/repoconv/verify/verify.cpp        2020-07-27 18:35:13 UTC 
(rev 76523)
@@ -360,10 +360,18 @@
     infile.close();
 }
 
+// trim whitespace - https://stackoverflow.com/a/49253841
+static inline void wtrim(std::string &s) {
+    if (s.empty()) return;
+    while (s.find(" ") == 0) {s.erase(0, 1);}
+    size_t len = s.size();
+    while (s.rfind(" ") == --len) { s.erase(len, len + 1); }
+}
+
 void
 get_branches(std::set<std::string> &branches, std::string &sha1, std::string 
&git_repo)
 {
-    std::string get_branch = std::string("cd ") + git_repo + std::string(" && 
git branch -a --contains ") + sha1 + std::string(" |sed -e 's/ /\\n/g' > 
../branches.txt && cd ..");
+    std::string get_branch = std::string("cd ") + git_repo + std::string(" && 
git branch -a --contains ") + sha1 + std::string(" > ../branches.txt && cd ..");
     run_cmd(get_branch);
     std::ifstream infile("branches.txt", std::ifstream::binary);
     if (!infile.good()) {
@@ -374,8 +382,11 @@
     std::string branch;
     int cnt = 0;
     std::set<std::string> b;
+    std::regex dregex(".*detached.*");
     while (std::getline(infile, line)) {
         if (!line.length()) continue;
+       if (std::regex_match(line, dregex)) continue;
+       wtrim(line);
        b.insert(line);
        cnt++;
     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to