]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Whitespace cleanup
authorMartin Vidner <mvidner@suse.cz>
Tue, 17 Dec 2019 09:41:23 +0000 (10:41 +0100)
committerMartin Vidner <mvidner@suse.cz>
Tue, 17 Dec 2019 10:22:26 +0000 (11:22 +0100)
zypp-plugin/snapper_zypp_plugin.cc
zypp-plugin/solvable_matcher.cc
zypp-plugin/zypp_plugin.h

index b9bbb99026fe66e588daa708b45781455806c832..702ae68c90af738c4d662385e85a46a79a2d19a7 100644 (file)
@@ -74,8 +74,8 @@ public:
 
        s = getenv("SNAPPER_ZYPP_PLUGIN_DBUS_SESSION");
        if (s != nullptr) {
-            bus = DBUS_BUS_SESSION;
-        }
+           bus = DBUS_BUS_SESSION;
+       }
     }
 };
 
@@ -118,12 +118,12 @@ public:
            try {
                cerr << "INFO:" << "creating pre snapshot" << endl;
                pre_snapshot_num = command_create_pre_snapshot(
-                    dbus_conn, snapper_cfg,
-                    snapshot_description, cleanup_algorithm, userdata
-                );
+                   dbus_conn, snapper_cfg,
+                   snapshot_description, cleanup_algorithm, userdata
+               );
                cerr << "DEBUG:" << "created pre snapshot " << pre_snapshot_num << endl;
            }
-            catch (const DBus::ErrorException& ex) {
+           catch (const DBus::ErrorException& ex) {
                SN_CAUGHT(ex);
                cerr << "ERROR:" << error_description(ex) << endl;
            }
@@ -156,9 +156,9 @@ public:
                    modification_data.cleanup = cleanup_algorithm;
                    modification_data.userdata = userdata;
                    command_set_snapshot(
-                        dbus_conn, snapper_cfg,
-                        pre_snapshot_num, modification_data
-                    );
+                       dbus_conn, snapper_cfg,
+                       pre_snapshot_num, modification_data
+                   );
                }
                catch (const DBus::ErrorException& ex) {
                    SN_CAUGHT(ex);
@@ -170,9 +170,9 @@ public:
                try {
                    cerr << "INFO:" << "creating post snapshot" << endl;
                    unsigned int post_snapshot_num = command_create_post_snapshot(
-                        dbus_conn, snapper_cfg,
-                        pre_snapshot_num, "", cleanup_algorithm, userdata
-                    );
+                       dbus_conn, snapper_cfg,
+                       pre_snapshot_num, "", cleanup_algorithm, userdata
+                   );
                    cerr << "DEBUG:" << "created post snapshot " << post_snapshot_num << endl;
                }
                catch (const DBus::ErrorException& ex) {
@@ -233,7 +233,7 @@ map<string, string> SnapperZyppPlugin::get_userdata(const Message& msg) {
     auto it = msg.headers.find("userdata");
     if (it != msg.headers.end()) {
        const string& userdata_s = it->second;
-        vector<string> key_values;
+       vector<string> key_values;
        boost::split(key_values, userdata_s, boost::is_any_of(","));
        for (auto kv: key_values) {
            static const snapper::Regex rx_keyval("^([^=]*)=(.+)$");
@@ -277,37 +277,37 @@ set<string> SnapperZyppPlugin::get_solvables(const Message& msg, Phase phase) {
     // https://doc.opensuse.org/projects/libzypp/SLE12SP2/plugin-commit.html
     json_object * steps = object_get(zypp, "TransactionStepList");
     if (!steps)
-        return result;
+       return result;
 
     if (json_object_get_type(steps) == json_type_array) {
-        size_t i, len = json_object_array_length(steps);
-        printf("steps: %zu\n", len);
-        for (i = 0; i < len; ++i) {
-            json_object * step = json_object_array_get_idx(steps, i);
-            bool have_type = json_object_object_get_ex(step, "type", NULL);
-            bool have_stage = json_object_object_get_ex(step, "stage", NULL);
-            if (have_type && (phase == Phase::BEFORE || have_stage)) {
-                json_object * solvable = object_get(step, "solvable");
-                if (!solvable) {
-                    cerr << "ERROR:" << "in item #" << i << endl;
-                    continue;
-                }
-                json_object * name = object_get(solvable, "n");
-                if (!name) {
-                    cerr << "ERROR:" << "in item #" << i << endl;
-                    continue;
-                }
-                if (json_object_get_type(name) != json_type_string) {
-                    cerr << "ERROR:" << "\"n\" is not a string" << endl;
-                    cerr << "ERROR:" << "in item #" << i << endl;
-                    continue;
-                }
-                else {
-                    const char * prize = json_object_get_string(name);
+       size_t i, len = json_object_array_length(steps);
+       printf("steps: %zu\n", len);
+       for (i = 0; i < len; ++i) {
+           json_object * step = json_object_array_get_idx(steps, i);
+           bool have_type = json_object_object_get_ex(step, "type", NULL);
+           bool have_stage = json_object_object_get_ex(step, "stage", NULL);
+           if (have_type && (phase == Phase::BEFORE || have_stage)) {
+               json_object * solvable = object_get(step, "solvable");
+               if (!solvable) {
+                   cerr << "ERROR:" << "in item #" << i << endl;
+                   continue;
+               }
+               json_object * name = object_get(solvable, "n");
+               if (!name) {
+                   cerr << "ERROR:" << "in item #" << i << endl;
+                   continue;
+               }
+               if (json_object_get_type(name) != json_type_string) {
+                   cerr << "ERROR:" << "\"n\" is not a string" << endl;
+                   cerr << "ERROR:" << "in item #" << i << endl;
+                   continue;
+               }
+               else {
+                   const char * prize = json_object_get_string(name);
                    result.insert(prize);
-                }
-            }
-        }
+               }
+           }
+       }
     }
 
     return result;
index 8bab2abc0a28f2a4244dbef07e5fdc2bc8140be6..fa77ef55bb81fbca17a4cc3bb39a4eb0a3003ed7 100644 (file)
@@ -15,19 +15,19 @@ std::ostream& SolvableMatcher::log = std::cerr;
 
 bool SolvableMatcher::match(const string& solvable) const {
     log << "DEBUG:"
-        << "match? " << solvable
-        << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '")
-        << pattern << '\'' << endl;
+       << "match? " << solvable
+       << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '")
+       << pattern << '\'' << endl;
     bool res;
     if (kind == Kind::GLOB) {
-        static const int flags = 0;
-        res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0;
+       static const int flags = 0;
+       res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0;
     }
     else {
-        // POSIX Extended Regular Expression Syntax
+       // POSIX Extended Regular Expression Syntax
        // The original Python implementation allows "foo" to match "foo-devel"
        snapper::Regex rx_pattern("^" + pattern, REG_EXTENDED | REG_NOSUB);
-        res = rx_pattern.match(solvable);
+       res = rx_pattern.match(solvable);
     }
     log << "DEBUG:" << "-> " << res << endl;
     return res;
@@ -42,27 +42,26 @@ vector<SolvableMatcher> SolvableMatcher::load_config(const string& cfg_filename)
     const xmlNode* solvables_n = getChildNode(root, "solvables");
     const list<const xmlNode*> solvables_l = getChildNodes(solvables_n, "solvable");
     for (auto node: solvables_l) {
-        string pattern;
-        Kind kind;
-        bool important = false;
+       string pattern;
+       Kind kind;
+       bool important = false;
 
-        getAttributeValue(node, "important", important);
-        string kind_s;
-        getAttributeValue(node, "match", kind_s);
-        getValue(node, pattern);
-        if (kind_s == "w") { // w for wildcard
-            kind = Kind::GLOB;
-        }
-        else if (kind_s == "re") { // Regular Expression
-            kind = Kind::REGEX;
-        }
-        else {
-            log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl;
-            continue;
-        }
+       getAttributeValue(node, "important", important);
+       string kind_s;
+       getAttributeValue(node, "match", kind_s);
+       getValue(node, pattern);
+       if (kind_s == "w") { // w for wildcard
+           kind = Kind::GLOB;
+       }
+       else if (kind_s == "re") { // Regular Expression
+           kind = Kind::REGEX;
+       }
+       else {
+           log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl;
+           continue;
+       }
 
-        result.emplace_back(SolvableMatcher(pattern, kind, important));
+       result.emplace_back(SolvableMatcher(pattern, kind, important));
     }
     return result;
 }
-
index 7750e9092ec8a33b44a6de713fa1c1d453da48b1..1cfa26b900577c5fbaac3a425ce1a2b88f0285c8 100644 (file)
@@ -10,8 +10,8 @@ public:
     // https://doc.opensuse.org/projects/libzypp/SLE12SP2/zypp-plugins.html
     struct Message {
        std::string command;
-       std::map<std::string, std::string> headers;
-       std::string body;
+       std::map<std::string, std::string> headers;
+       std::string body;
     };
 
     virtual int main();