From 63b70ddb06b2d35317a518b12baebf72297c227b Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 30 Dec 2019 09:42:23 +0500 Subject: [PATCH] move http module to net.http --- .github/workflows/ci.yml | 4 ++-- examples/links_scraper.v | 2 +- examples/news_fetcher.v | 2 +- tools/vfmt.v | 5 +++++ tools/vpm.v | 2 +- vlib/{ => net}/http/backend_nix.v | 0 vlib/{ => net}/http/backend_windows.v | 0 vlib/{ => net}/http/chunked/dechunk.v | 0 vlib/{ => net}/http/download.v | 2 +- vlib/{ => net}/http/download_nix.v | 0 vlib/{ => net}/http/download_windows.v | 0 vlib/{ => net}/http/http.v | 2 +- vlib/{ => net}/http/http_client.v | 0 vlib/{ => net}/http/http_test.v | 2 +- vlib/vweb/vweb.v | 2 +- 15 files changed, 14 insertions(+), 9 deletions(-) rename vlib/{ => net}/http/backend_nix.v (100%) rename vlib/{ => net}/http/backend_windows.v (100%) rename vlib/{ => net}/http/chunked/dechunk.v (100%) rename vlib/{ => net}/http/download.v (93%) rename vlib/{ => net}/http/download_nix.v (100%) rename vlib/{ => net}/http/download_windows.v (100%) rename vlib/{ => net}/http/http.v (99%) rename vlib/{ => net}/http/http_client.v (100%) rename vlib/{ => net}/http/http_test.v (98%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 344d8f1cbb..9d51017620 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: run: make -j4 - name: Build a production tools/vfmt run: ./v -prod -d vfmt tools/vfmt.v - - name: fmt only the changed files (from master) - run: git diff --name-status origin/master HEAD -- '*.v' |grep -v '^D'|rev|cut -f1|rev| xargs ./v fmt -diff + - name: Run v fmt -diff on only the changed files. Does NOT fail for now. + run: git diff --name-status origin/master HEAD -- '*.v' |grep -v '^D'|rev|cut -f1|rev| xargs ./v fmt -noerror -diff - name: Run v test-fmt run: ./v test-fmt diff --git a/examples/links_scraper.v b/examples/links_scraper.v index bde0a632e6..d543211f26 100644 --- a/examples/links_scraper.v +++ b/examples/links_scraper.v @@ -1,4 +1,4 @@ -import http +import net.http fn main() { html := http.get_text('https://news.ycombinator.com') diff --git a/examples/news_fetcher.v b/examples/news_fetcher.v index b287e19e89..73c226db54 100644 --- a/examples/news_fetcher.v +++ b/examples/news_fetcher.v @@ -1,7 +1,7 @@ // Copyright (c) 2019 Alexander Medvednikov. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. -import http +import net.http import json import sync diff --git a/tools/vfmt.v b/tools/vfmt.v index 3ce80fc1a7..d0e0da1409 100644 --- a/tools/vfmt.v +++ b/tools/vfmt.v @@ -19,6 +19,7 @@ struct FormatOptions { is_all bool is_worker bool is_debug bool + is_noerror bool } const ( @@ -44,6 +45,7 @@ fn main() { is_all: '-all' in args || '--all' in args is_worker: '-worker' in args is_debug: '-debug' in args + is_noerror: '-noerror' in args } if foptions.is_verbose { eprintln('vfmt foptions: $foptions') @@ -104,6 +106,9 @@ fn main() { } if errors > 0 { eprintln('Encountered a total of: ${errors} errors.') + if foptions.is_noerror { + exit(0) + } exit(1) } } diff --git a/tools/vpm.v b/tools/vpm.v index 26827f9131..5b09cbfca4 100644 --- a/tools/vpm.v +++ b/tools/vpm.v @@ -1,7 +1,7 @@ module main import ( - http + net.http os json filepath diff --git a/vlib/http/backend_nix.v b/vlib/net/http/backend_nix.v similarity index 100% rename from vlib/http/backend_nix.v rename to vlib/net/http/backend_nix.v diff --git a/vlib/http/backend_windows.v b/vlib/net/http/backend_windows.v similarity index 100% rename from vlib/http/backend_windows.v rename to vlib/net/http/backend_windows.v diff --git a/vlib/http/chunked/dechunk.v b/vlib/net/http/chunked/dechunk.v similarity index 100% rename from vlib/http/chunked/dechunk.v rename to vlib/net/http/chunked/dechunk.v diff --git a/vlib/http/download.v b/vlib/net/http/download.v similarity index 93% rename from vlib/http/download.v rename to vlib/net/http/download.v index e24ccfdc1b..68be9ed20f 100644 --- a/vlib/http/download.v +++ b/vlib/net/http/download.v @@ -6,7 +6,7 @@ module http import os pub fn download_file(url, out string) bool { - s := http.get(url) or { + s := get(url) or { return false } os.write_file(out, s.text) diff --git a/vlib/http/download_nix.v b/vlib/net/http/download_nix.v similarity index 100% rename from vlib/http/download_nix.v rename to vlib/net/http/download_nix.v diff --git a/vlib/http/download_windows.v b/vlib/net/http/download_windows.v similarity index 100% rename from vlib/http/download_windows.v rename to vlib/net/http/download_windows.v diff --git a/vlib/http/http.v b/vlib/net/http/http.v similarity index 99% rename from vlib/http/http.v rename to vlib/net/http/http.v index 765a88e83f..3f8acdcc32 100644 --- a/vlib/http/http.v +++ b/vlib/net/http/http.v @@ -4,7 +4,7 @@ module http import net.urllib -import http.chunked +import net.http.chunked const ( max_redirects = 4 diff --git a/vlib/http/http_client.v b/vlib/net/http/http_client.v similarity index 100% rename from vlib/http/http_client.v rename to vlib/net/http/http_client.v diff --git a/vlib/http/http_test.v b/vlib/net/http/http_test.v similarity index 98% rename from vlib/http/http_test.v rename to vlib/net/http/http_test.v index b85a91751c..08edb2e981 100644 --- a/vlib/http/http_test.v +++ b/vlib/net/http/http_test.v @@ -1,5 +1,5 @@ // import net.urllib -import http +import net.http fn test_escape_unescape() { /* diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 667ce00dbe..650a15ab9d 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -7,7 +7,7 @@ module vweb import ( os net - http + net.http net.urllib strings )