Class: QCloudHive::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/qcloudhive/repo.rb

Class Method Summary collapse

Class Method Details

.addChildSpec(parentName, subHiveSpec) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/qcloudhive/repo.rb', line 164

def Repo.addChildSpec(parentName, subHiveSpec)
  faceParentHiveSpec = subFackSpec(parentName)
  spec = faceParentHiveSpec.podspec
  subSpec = subHiveSpec.podspec
  sourceFiles = subSpec.attributes_hash["source_files"]
  if sourceFiles.is_a?(String)
    sourceFiles = subHiveSpec.path.parent.join(sourceFiles).to_path
  end
  subSpec.source_files = sourceFiles
  spec.subspec subHiveSpec.name,subSpec
  faceParentHiveSpec.writeJson
end

.checkGitStatus(git, tableRows) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/qcloudhive/repo.rb', line 50

def Repo.checkGitStatus(git, tableRows)
   git.status.changed.each do |path, statu|
    tableRows << ["", "", statu.type.red, path.red]
   end
   git.status.deleted.each do |path, statu|
     tableRows << ["", "", statu.type.red, path.red]
   end
   git.status.added.each do |path, statu|
     tableRows << ["","", statu.type.red, path.red]
   end
   git.status.untracked.each do |path, statu|
     tableRows << ["", "", "U".red, path.red]
   end
end

.checkStatus(cmd, opts) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/qcloudhive/repo.rb', line 64

def Repo.checkStatus(cmd, opts)
    projectTable = []
    Config.manifest.projects.each { |p|
      projectTable << ["#{p.path}".red, "Branche" ,p.gitRepo.clean? ? "clean".green : "dirty".red]
      if not p.exsitServer?
        projectTable << ["", "远端没有该模块,请提交" ]
      else
        if  not p.exsitPodRepo?
          projectTable << ["", "", "", "🐝🐝请提交该模块到Pod仓库"]
        else

          if p.needReleasePod?
            projectTable << ["", "", "", "🐝🐝提交该模块的新修改到Pod仓库"]
          end
        end
        #
        projectTable << [p.moduleName]
        currentBranch = p.gitRepo.branches[p.gitRepo.current_branch]
        currentFreature = ProjectFeature.new(p, currentBranch)
        if currentFreature.remoteBranch.nil?
          projectTable << ["", currentBranch.full,"", "远端没有该分支,请及时提交到服务器 ⬆️⬆️⬆️⬆️".red]
        else
          compareRet = currentFreature.compareRemote
          if compareRet == 1
            projectTable << ["", "","" ,"本地有未同步的修改,请及时提交到服务器 ⬆️⬆️⬆️⬆️".red]
          elsif compareRet == -1
            projectTable << ["", "","" ,"远端有新的修改,请及时Pull⬇️⬇️⬇️".blue]
          else
            projectTable << ["", "","" ,""]
          end
          compareMaster = currentFreature.compareMaster
          if compareMaster == 1
            projectTable << ["", "","" ,"领先于master分支,请留意进行merge request!!!"]
          elsif compareMaster == -1
            projectTable << ["", "","" ,"落后于master分支有差异,请留意合并master的修改!!!"]
          end
        end
      end
      checkGitStatus(p.gitRepo, projectTable)
      projectTable << :separator
    }
    table = Terminal::Table.new :rows => projectTable
    puts table
end

.clean?(git) ⇒ Boolean

Returns:

  • (Boolean)


128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/qcloudhive/repo.rb', line 128

def Repo.clean?(git)
  root = Pathname(Config.projectRootDirectory)
  Config.manifest.projects.each { |p|
    path = root.join(p.path)
    begin
      g = Git.open(path)
      L.debug "#{g} #{g.clean?}"
    rescue => err
      puts "读取git工程失败 #{path} #{err}"
    end
  }
end

.fackSpec(name) ⇒ Object



141
142
143
# File 'lib/qcloudhive/repo.rb', line 141

def Repo.fackSpec(name)

end

.fackSpecContainerPathObject



145
146
147
148
149
150
151
# File 'lib/qcloudhive/repo.rb', line 145

def Repo.fackSpecContainerPath
    fackPath = Pathname(Config.projectRootDirectory).join(".fackspec")
    if not fackPath.exist?
      fackPath.mkdir
    end
  return fackPath.to_path
end

.push(cmd, opts) ⇒ Object



20
21
22
# File 'lib/qcloudhive/repo.rb', line 20

def Repo.push(cmd, opts)

end

.relaseCommits(name) ⇒ Object



24
25
26
# File 'lib/qcloudhive/repo.rb', line 24

def Repo.relaseCommits(name)

end

.request(cmd, opts) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/qcloudhive/repo.rb', line 27

def Repo.request(cmd, opts)
  git = Git.open(Dir.pwd)
  if git == nil
    Error("当前不是Git目录")
  end
  message = GetOptValue(cmd, opts, :i_message)
  if git.current_branch == "master"
    Error "无法将master分支合并到master分支"
  end
  name = QCloudHive::GITURLDecoder.new(git.remote.url).name
  L.debug name
  project = CodeOA.existProjectByName?(name)
  if project ==  nil
    Error "工程还没有在CodeOA上创建!!#{name}"
  end
  begin
    L.info "#{project.id} #{git.current_branch}"
    Gitlab.create_merge_request(project.id, message, :source_branch=>git.current_branch, :target_branch=>"master")
  rescue => err
    Error "创建失败#{err}"
  end
end

.status(git) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/qcloudhive/repo.rb', line 108

def Repo.status(git)
    if git.remotes.count == 0
      Error "您没有设置改模块的远端地址,请设置!!!#{path}"
    end
    L.debug "#{git.clean?}"
    changedCount = 0
    git.status.each { |statu|
      tag = nil
      if statu.type != nil
        tag = statu.type.red
      elsif statu.untracked == true
        tag = "U".red
      end
      if tag != nil
        changedCount += 0
        printf "%-60s %s \n", statu.path, tag
      end
    }
end

.subFackSpec(name, rebuild = true) ⇒ Object



153
154
155
156
157
158
159
160
161
162
# File 'lib/qcloudhive/repo.rb', line 153

def Repo.subFackSpec(name, rebuild=true)
  fackpath = fackSpecContainerPath+"/#{name}"
  if rebuild == true
    if Pathname(fackpath).exist?
      FileUtils.rm_rf(fackpath)
    end
  end
  HiveModule.createLocalModule(name, fackpath)
  return HiveSpec.new(name, fackpath+"/#{name}.podspec")
end