ggsm 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 996c39374cb11250d79913de7faf12ae2730290b
4
- data.tar.gz: 5045631bff91d67cf68cf1595869b5dc0715094d
3
+ metadata.gz: dd8da8540d6e4e736ff782af1c43fb71b08d95ea
4
+ data.tar.gz: 571682bd82ddf00beec4397a219c057b83993b0a
5
5
  SHA512:
6
- metadata.gz: fd593cfc4cb21c7fc66f51fcacb431ab913f44fd4f58bd95449ec0323de2a3f00e34776a7ac1e50939d62a4df68bb0f1d0226b90f1b367d1335cfd30f9067c8e
7
- data.tar.gz: 648ea7a0822727659814fdb4938a1767a1368f955d0b78a2dbf52d055d39990ad254c11edc6a2c169049f286fc841319660499b0819ce35287550ac0d0752da7
6
+ metadata.gz: e0a269fc7173ec80d4caa9716ebf5a0f228c520bb4a8067a4dc68f7dc2bc6dd192fbf48bcbc58ee9df6cade109cf447ca63015c634d50c6e86a95923e77db5ca
7
+ data.tar.gz: c9c6fd2df3576848858315683ba6beefe870e21de8d6f93f7a162a5964363c5dfe071613a4cae3ef7dc6a7e6aa6ac4b0da40ae5ee25090520dc93c783206ceb4
@@ -19,19 +19,38 @@ module GGSM
19
19
  end
20
20
 
21
21
  def delete_branch(all, branch, remote)
22
+ if branch == get_current_branch
23
+ puts "无法删除当前所在分支:#{branch},请switch其他分支后再执行\"ggsm delete\"".red
24
+ exit 0
25
+ end
26
+
22
27
  if all
23
- system "git branch -D #{branch}"
24
- result = system "git push origin -d #{branch}"
25
- unless result
26
- system 'git fetch -p origin'
27
- end
28
+ delete_local_branch(branch)
29
+ delete_remote_branch(branch)
28
30
  elsif remote
29
- result = system "git push origin -d #{branch}"
30
- unless result
31
- system 'git fetch -p origin'
31
+ delete_remote_branch(branch)
32
+ else
33
+ delete_local_branch(branch)
34
+ end
35
+ end
36
+
37
+ def delete_local_branch(branch)
38
+ if `git branch | grep -e '\s|*#{branch}$'`.strip == ''
39
+ puts "warning: branch '#{branch}' not found"
40
+ else
41
+ info = `git branch -D #{branch}`
42
+ if info.strip != ''
43
+ puts "✓ #{info}"
32
44
  end
45
+ end
46
+ end
47
+
48
+ def delete_remote_branch(branch)
49
+ if `git branch -r | grep -e '\s|*origin/#{branch}$'`.strip == ''
50
+ puts "warning: remote branch '#{branch}' not found"
33
51
  else
34
- system "git branch -D #{branch}"
52
+ system "git push origin -d #{branch}"
53
+ `git fetch -p origin`
35
54
  end
36
55
  end
37
56
  end
@@ -25,14 +25,18 @@ module GGSM
25
25
  if branch.include?('rebas')
26
26
  system 'git rebase --continue'
27
27
  else
28
- system 'git commit'
28
+ stage = `git diff --cached --name-only`.strip
29
+ if stage == ''
30
+ `git commit`
31
+ else
32
+ result = system 'git commit'
33
+ unless result
34
+ exit 1
35
+ end
36
+ end
29
37
  end
30
38
 
31
- if force
32
- system "git push -u origin #{get_current_branch} -f"
33
- else
34
- system "git push -u origin #{get_current_branch}"
35
- end
39
+ `git push -u origin #{get_current_branch} #{force ? '-f' : ''}`
36
40
  end
37
41
  end
38
42
  end
@@ -17,7 +17,7 @@ module GGSM
17
17
  arry_commit_not_exist = []
18
18
 
19
19
  need_stash = try_stash
20
- result = system "git checkout #{branch}"
20
+ `git checkout #{branch}`; result=$?.success?
21
21
  if need_stash
22
22
  stash_pop(arry_conflict, '主工程')
23
23
  end
@@ -50,12 +50,13 @@ module GGSM
50
50
 
51
51
  def process_switch(commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
52
52
  need_stash = try_stash
53
- result = system "git checkout #{branch}"
53
+
54
+ `git checkout #{branch}`; result=$?.success?
54
55
 
55
56
  if result
56
57
  commit = sub_commits.fetch(index);
57
- commit_exist = system "git reset --hard #{commit}"
58
- unless commit_exist
58
+ `git reset --hard #{commit}`; result=$?.success?
59
+ unless result
59
60
  commit_not_exist.push("==> #{sub}模块不存在远程commit:#{commit}")
60
61
  end
61
62
  else
@@ -1,3 +1,3 @@
1
1
  module GGSM
2
- VERSION = '1.7.1'
2
+ VERSION = '1.7.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ggsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - YoKey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler