From e8c135d3b2d83b8410bc232d3a1cd766fa90cbdb Mon Sep 17 00:00:00 2001 From: kaushiks15103 Date: Wed, 30 Jan 2019 15:13:21 +0530 Subject: [PATCH 1/4] Pre push hook testing 13 --- .../src/main/java/com/test5/test5/Test5Application.java | 5 +++++ .../java/com/test5/test5/controllers/hotelcontroller.java | 2 -- proj1/src/app/components/userlogin/userlogin.component.ts | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend-services/test5/src/main/java/com/test5/test5/Test5Application.java b/backend-services/test5/src/main/java/com/test5/test5/Test5Application.java index ff6d7e1..50c1e27 100644 --- a/backend-services/test5/src/main/java/com/test5/test5/Test5Application.java +++ b/backend-services/test5/src/main/java/com/test5/test5/Test5Application.java @@ -22,6 +22,11 @@ public FilterRegistrationBean loggingFilter(){ authBean.setFilter(new AuthFilter()); authBean.addUrlPatterns("/JwtAuth/*"); return authBean; + + + + + } public static void main(String[] args) { SpringApplication.run(Test5Application.class, args); diff --git a/backend-services/test5/src/main/java/com/test5/test5/controllers/hotelcontroller.java b/backend-services/test5/src/main/java/com/test5/test5/controllers/hotelcontroller.java index d28786c..d5b3013 100644 --- a/backend-services/test5/src/main/java/com/test5/test5/controllers/hotelcontroller.java +++ b/backend-services/test5/src/main/java/com/test5/test5/controllers/hotelcontroller.java @@ -16,8 +16,6 @@ import com.test5.test5.models.hotels; import com.test5.test5.repo.hotelrespository; - - @RestController @RequestMapping("/api") @CrossOrigin("http://localhost:4200") diff --git a/proj1/src/app/components/userlogin/userlogin.component.ts b/proj1/src/app/components/userlogin/userlogin.component.ts index 85a1d2a..c1cc985 100644 --- a/proj1/src/app/components/userlogin/userlogin.component.ts +++ b/proj1/src/app/components/userlogin/userlogin.component.ts @@ -37,5 +37,3 @@ export class UserloginComponent implements OnInit { } } - - From 7a5d858412e382b0227d39e01e57f60bd58aad95 Mon Sep 17 00:00:00 2001 From: kaushiks15103 Date: Wed, 30 Jan 2019 17:41:25 +0530 Subject: [PATCH 2/4] Services refactored - Angular --- proj1/src/app/services/addhotel.service.ts | 20 ++--- .../src/app/services/book-service.service.ts | 20 ++--- proj1/src/app/services/flight.service.ts | 10 +-- proj1/src/app/services/hot-deals.service.ts | 82 ------------------- .../app/services/register-service.service.ts | 14 ++-- proj1/src/app/services/token.service.ts | 2 +- 6 files changed, 32 insertions(+), 116 deletions(-) delete mode 100644 proj1/src/app/services/hot-deals.service.ts diff --git a/proj1/src/app/services/addhotel.service.ts b/proj1/src/app/services/addhotel.service.ts index 34dd269..d2cfffe 100644 --- a/proj1/src/app/services/addhotel.service.ts +++ b/proj1/src/app/services/addhotel.service.ts @@ -7,30 +7,28 @@ import { map, catchError, tap } from 'rxjs/operators'; }) export class AddhotelService { - endpoint = 'http://localhost:3000/api/v1/'; - httpOptions = { + endpoint = 'http://localhost:3000/api/v1/'; + httpOptions = { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + 'Content-Type': 'application/json' }) }; result; - constructor(private http:HttpClient) { } + constructor(private http: HttpClient) { } private extractData(res: Response) { - let body = res; - return body || { }; + const body = res; + return body || {}; } getProducts(): Observable { return this.http.get('http://localhost:8080/api/gethotels').pipe( map(this.extractData)); } - public postUser(data){ - console.log(data) - this.http.post("http://localhost:8080/api/addhotel/",data).subscribe(res=>{this.result=res;console.log(this.result);}); + public postUser(data) { + this.http.post('http://localhost:8080/api/addhotel/', data).subscribe(res => { this.result = res; console.log(this.result); }); } getProduct(data): Observable { - console.log(data) - return this.http.post("http://localhost:8080/api/getHotel/",data) + return this.http.post('http://localhost:8080/api/getHotel/', data); } } diff --git a/proj1/src/app/services/book-service.service.ts b/proj1/src/app/services/book-service.service.ts index 9c03b6d..13ef8c6 100644 --- a/proj1/src/app/services/book-service.service.ts +++ b/proj1/src/app/services/book-service.service.ts @@ -6,26 +6,26 @@ import { HttpClientModule, HttpClient, HttpHeaders } from '@angular/common/http' }) export class BookServiceService { - private details:any; + private details: any; - token:any; + token: any; - constructor(private http:HttpClient) { } + constructor(private http: HttpClient) { } - setDetails(details:any){ + setDetails(details: any) { console.log(details); this.details = details; } - getDetails(){ + getDetails() { return this.details; } - bookTicket(bookDetails:any){ + bookTicket(bookDetails: any) { this.token = localStorage.getItem('token'); - const headers= new HttpHeaders({ - 'token':this.token - }) - return this.http.post("http://localhost:8080/JwtAuth/book/",bookDetails,{headers:headers,observe:'response' as 'body'}); + const headers = new HttpHeaders({ + 'token': this.token + }); + return this.http.post('http://localhost:8080/JwtAuth/book/', bookDetails, { headers: headers, observe: 'response' as 'body' }); } } diff --git a/proj1/src/app/services/flight.service.ts b/proj1/src/app/services/flight.service.ts index a2de7ff..51745d7 100644 --- a/proj1/src/app/services/flight.service.ts +++ b/proj1/src/app/services/flight.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from "@angular/core"; -import { HttpClient, HttpHeaders } from "@angular/common/http"; +import { Injectable } from '@angular/core'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; @Injectable({ - providedIn: "root" + providedIn: 'root' }) export class FlightService { constructor(private http: HttpClient) { } @@ -12,11 +12,11 @@ export class FlightService { getFlights(searchDetails: any) { console.log('input' + searchDetails); - return this.http.post("http://localhost:8080/api/getFlight/", searchDetails); + return this.http.post('http://localhost:8080/api/getFlight/', searchDetails); } getHotDeals() { - return this.http.get("http://localhost:8080/api/getFlights"); + return this.http.get('http://localhost:8080/api/getFlights'); } } diff --git a/proj1/src/app/services/hot-deals.service.ts b/proj1/src/app/services/hot-deals.service.ts deleted file mode 100644 index 41f71e2..0000000 --- a/proj1/src/app/services/hot-deals.service.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class HotDealsService { - - constructor() { } - - city: any[]=[{ - flightName:"Madurai", - price:"Madurai-Chennai", - image:"https://www.travelsupermarket.com/content/dam/travelsupermarket/Hub_content_images/last-minute/lastminute-flight.jpg" - }, - { - flightName:"Chennai", - price:"Chennai-Dubai", - image:"https://imgak.mmtcdn.com/pwa-hlp/assets/img/hlp/deals/ic-flight-14.jpg" - }, - { - flightName:"Delhi", - price:"Delhi-Sikkim", - image:"http://travelguysradio.com/wp-content/uploads/2016/05/maxresdefault.jpg" - } -]; - -flights:any[] = [ - { - flightName:"Mumbai", - price : "1200", - image:"https://www.imore.com/sites/imore.com/files/styles/xlarge/public/field/image/2017/02/airplane-flight-sunset.jpg?itok=8iUtkHU-" - }, - { - flightName:"Chennai", - price : "1300", - image: "https://fm.cnbc.com/applications/cnbc.com/resources/img/editorial/2018/06/01/105245766-Singapore-Airlines-A350URL.1910x1000.jpg" - }, - { - flightName:"Madurai", - price : "1400", - image: "https://www.livemint.com/rf/Image-621x414/LiveMint/Period2/2018/09/04/Photos/Processed/indigo-kDEC--621x414@LiveMint.jpg" - }, - { - flightName:"kolkata", - price : "2000", - image:"https://www.imore.com/sites/imore.com/files/styles/xlarge/public/field/image/2017/02/airplane-flight-sunset.jpg?itok=8iUtkHU-" - }, - { - flightName:"Sikkim", - price : "1400", - image:"https://www.imore.com/sites/imore.com/files/styles/xlarge/public/field/image/2017/02/airplane-flight-sunset.jpg?itok=8iUtkHU-" - }, - { - flightName:"Nepal", - price : "2500", - image:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDBw83Kx6y_uUBZ02EVP-G290plaoOTfaEj32s2c6BkaSj0ZrR1Q" - }, - { - flightName:"manipur", - price : "2300", - image:"http://www.berjaya-air.com/data/uploads/web-banner.jpg" - }, - { - flightName:"kashmir", - price : "2300", - image:"https://media.cntraveller.in/wp-content/uploads/2018/01/CE63NW-Cropped-866x487.jpg" - }, - { - flightName:"indore", - price : "2300", - image:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDBw83Kx6y_uUBZ02EVP-G290plaoOTfaEj32s2c6BkaSj0ZrR1Q" - }, - - ]; - - getDetails(){ - return this.city; - } - getFlightDetails(){ - return this.flights; - } -} diff --git a/proj1/src/app/services/register-service.service.ts b/proj1/src/app/services/register-service.service.ts index 89e8ea4..5916282 100644 --- a/proj1/src/app/services/register-service.service.ts +++ b/proj1/src/app/services/register-service.service.ts @@ -6,13 +6,13 @@ import { HttpClient } from '@angular/common/http'; }) export class RegisterServiceService { result; - constructor(private http:HttpClient) { } - public postUser(email:String,password:String){ - var options = { - email : email, - password : password - + constructor(private http: HttpClient) { } + public postUser(email: String, password: String) { + const options = { + email: email, + password: password + }; - return this.http.post("http://localhost:8080/api/register/",options).subscribe(res=>{this.result=res;console.log(this.result);}); + return this.http.post('http://localhost:8080/api/register/', options).subscribe(res => { this.result = res; }); } } diff --git a/proj1/src/app/services/token.service.ts b/proj1/src/app/services/token.service.ts index 9bc0225..1615bb6 100644 --- a/proj1/src/app/services/token.service.ts +++ b/proj1/src/app/services/token.service.ts @@ -24,4 +24,4 @@ export class TokenInterceptor implements HttpInterceptor { return next.handle(request); } -} \ No newline at end of file +} From 8ea1f9573c0e4b942f405a6aaa36caefc9619318 Mon Sep 17 00:00:00 2001 From: kaushiksivaram11 Date: Thu, 31 Jan 2019 12:59:27 +0530 Subject: [PATCH 3/4] Hooks Folder Added --- hooks/pre-push | 60 ++++++++++++++++++++++ tools/java-linting-tools/google_checks.xml | 3 -- tools/pre-commit.py | 7 +-- 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 hooks/pre-push diff --git a/hooks/pre-push b/hooks/pre-push new file mode 100644 index 0000000..d6d555c --- /dev/null +++ b/hooks/pre-push @@ -0,0 +1,60 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" +BASEDIR=$(eval 'realpath ./tools/pre-commit.py') +ROOTDIR=$(eval 'realpath .') +result=$(eval 'python $BASEDIR "$ROOTDIR" ') + +if [ "$result" == "0" ]; then + exit 1 +fi + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/tools/java-linting-tools/google_checks.xml b/tools/java-linting-tools/google_checks.xml index 2ad6787..dda4d93 100644 --- a/tools/java-linting-tools/google_checks.xml +++ b/tools/java-linting-tools/google_checks.xml @@ -23,9 +23,6 @@ - - - diff --git a/tools/pre-commit.py b/tools/pre-commit.py index 2463ea5..adf4655 100644 --- a/tools/pre-commit.py +++ b/tools/pre-commit.py @@ -21,9 +21,10 @@ def fun(): sys.stderr.write(cmd) elif os.path.splitext(base)[1] == '.java': # print(basepath+i) - cmd = os.popen('java -jar ' + basepath+'tools\\java-linting-tools\\checkstyle-8.17-all.jar -c '+basepath + 'tools\\java-linting-tools\\sun_checks.xml ' + basepath+i).read() - # print(cmd) - # sys.stderr.write(str(len(cmd))) + cmd = os.popen('java -jar ' + basepath+'tools\\java-linting-tools\\checkstyle-8.17-all.jar -c '+basepath + 'tools\\java-linting-tools\\google_checks.xml ' + basepath+i).read() + cmd = cmd.splitlines() + cmd.remove('Starting audit...') + cmd.remove('Audit done.') if len(cmd) != 0: isLintingProper = 0 sys.stderr.write(basepath+i) From 2dd49df0376999a25dc7f264745d4bef96fd0278 Mon Sep 17 00:00:00 2001 From: kaushiksivaram11 Date: Thu, 31 Jan 2019 13:31:44 +0530 Subject: [PATCH 4/4] Updated pre-commit.py --- tools/pre-commit.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/pre-commit.py b/tools/pre-commit.py index 083e4b0..be05e07 100644 --- a/tools/pre-commit.py +++ b/tools/pre-commit.py @@ -3,8 +3,7 @@ import subprocess import sys from glob import glob -def fun(): - sys.stderr.write("Hiiiii") +def fun(): commitids = os.popen('git log --format="%H" -n 2').read() commitids = commitids.splitlines() diff = os.popen('git diff --name-only ' + commitids[0] + ' ' + commitids[1]).read() @@ -19,17 +18,22 @@ def fun(): if len(cmd) != 0: isLintingProper = 0 sys.stderr.write(i) - sys.stderr.write(cmd) + sys.stderr.write(str(cmd)) elif os.path.splitext(base)[1] == '.java': # print(basepath+i) cmd = os.popen('java -jar ' + basepath+'tools\\java-linting-tools\\checkstyle-8.17-all.jar -c '+basepath + 'tools\\java-linting-tools\\google_checks.xml ' + basepath+i).read() + errors = cmd cmd = cmd.splitlines() - cmd.remove('Starting audit...') - cmd.remove('Audit done.') + if cmd.count('Starting audit...') != 0: + cmd.remove('Starting audit...') + if cmd.count('Audit done.') != 0: + cmd.remove('Audit done.') + if cmd.count('Files to process must be specified, found 0.') != 0: + cmd.remove('Files to process must be specified, found 0.') if len(cmd) != 0: isLintingProper = 0 sys.stderr.write(basepath+i) - sys.stderr.write(cmd) + sys.stderr.write(str(errors)) return isLintingProper